Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Reading XML with PHP
March 16, 2007, 9:47 am
rate this thread
First of all I want to say I do not have very clear understanding of
XML and PHP and what you can do with those two.
Now the problem I have is:
There is that booking company that sends data to me via XML and I have
in my server to read that XML and store it in a DB.
What I have no Idea how to do is read that XML.
To start with, I though they were using $_POST to upload an XML file,
but it seems they do not as when I get a request in my script I
print_r the $_POST and it is empty. The same with $_GET, empty.
Do you have any idea of other ways that they might send the XML data
and how can I read them with a PHP4 script?
Re: Reading XML with PHP
First of all, a short tutorial about uploading (sending it to your server)
files with PHP can be found there:
When the file is stored on the server you can read it as usual with fopen,
fread, fclose etc.
Of course, if you want to parse the XML file that's a bit more complicated.
I suggest you to look for a class on www.phpclasses.org
A very good class that is also used by Joomla and Mambo CMS (among others)
is DOMIT! XML Parser by John Heinstein: