tags:

views:

44

answers:

2

Hello guys,'

may be i am going to ask some stupid question but i don't have any idea about php that's why i want to know it i never worked in php and now i have to do it so please provide me some useful tips, i have XML file that is coming from a different URL and i want to save it on the server then i have to read it and extract it to a page in proper format and some modification in data.

+3  A: 

You can use DOM

$dom = new DOMDocument();
$dom->load('http://www.example.com');

This would load the XML from the remote URL. You can then process it as needed. See my previous answers on various topics using DOM. To save the file to your server after your processed it, you use

$dom->save('filename.xml');

Loading the file with $dom->load() will only work if you have allow_url_fopen enabled in your php.ini. If not, you have to use cURL to download the remote file first.

Gordon
dude i did it and i got message this[function.DOMDocument-load]: failed to open stream: no suitable wrapper could be found in D:\Hosting\5676400\html\myPhp\temp\xmlSearchresult.php on line 161
Abhisheks.net
@Abhisheks see my note about `allow_url_fopen`. On a sidenote, please improve your accept rate.
Gordon
ok thnk you to reply, and i don't know hows it improve ...
Abhisheks.net
@Abhisheks from the FAQ: *When you have decided which answer is the most helpful to you, mark it as the accepted answer by clicking on the check box outline to the left of the answer. This lets other people know that you have received a good answer to your question. Doing this is helpful because it shows other people that you're getting value from the community. (If you don't do this, people will often politely ask you to go back and accept answers for more of your questions!)*
Gordon
ohhh tha good , ok from the now i will doo it
Abhisheks.net
dear can you help me more, because i am not getting what i should to get it ? if you can then post my all the code here so that you can understand everything ..
Abhisheks.net
@Abhisheks put up a new question with your code and explanation what it is supposed to do and how it is not working, along with any errors you get.
Gordon
OK, i am posting a new question please find out some solution , i see your php answer's i know you have a good knowledge of php.
Abhisheks.net
A: 

Maybe this should be helpfull to you: http://www.php.net/manual/en/function.simplexml-load-file.php

If you're have dificulte to get the XML file from the remote host you can use combine with above simplexml-load-string

$path_to_xml = 'http://some.com/file.xml';
$xml = simplexml_load_string( file_get_content($path_to_xml) );
HWTech
Yes, but wont work with `allow_url_fopen` disabled either.
Gordon