Connecting Tech Pros Worldwide Help | Site Map

Reading XML with PHP

Aggelos
Guest
 
Posts: n/a
#1: Mar 16 '07
Hello,
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?

Thank you.

Mathias K.
Guest
 
Posts: n/a
#2: Mar 16 '07

re: Reading XML with PHP


Am 16 Mar 2007 02:47:32 -0700 schrieb Aggelos:
Quote:
Hello,
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?
>
Thank you.
Hello Aggelos!

First of all, a short tutorial about uploading (sending it to your server)
files with PHP can be found there:
http://www.phpjabbers.com/file-uploa...php-php18.html

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:
http://www.phpclasses.org/browse/package/1468.html

Good luck.


~ MK
Aggelos
Guest
 
Posts: n/a
#3: Mar 16 '07

re: Reading XML with PHP


OK Sollution to the problem found !!!
ALl the data were coming to the following variable, and that's why I
couldn't read them VIA $_POST
$HTTP_RAW_POST_DATA

If you have any comments or suggestions, I will be happy to read
them :)

THank you.

Aggelos
Guest
 
Posts: n/a
#4: Mar 16 '07

re: Reading XML with PHP


>
Quote:
First of all, a short tutorial about uploading (sending it to your server)
files with PHP can be found there:http://www.phpjabbers.com/file-uploa...php-php18.html
>
THank you but my problem was that they do not do a $_FILE post, just a
$_POST of an XML string...
ANd I caught that via $HTTP_RAW_POST_DATA.
:)

Thanks for the parsing class tip though ;)



Rik
Guest
 
Posts: n/a
#5: Mar 16 '07

re: Reading XML with PHP


On Fri, 16 Mar 2007 12:26:31 +0100, Aggelos <djjelly@gmail.comwrote:
Quote:
OK Sollution to the problem found !!!
ALl the data were coming to the following variable, and that's why I
couldn't read them VIA $_POST
$HTTP_RAW_POST_DATA
>
If you have any comments or suggestions, I will be happy to read
them :)
Could be that they're sending you an XML-file rather then 'just' XML, then
it would be in the $_FILES array.

Also, reading php://input can be very handy to determine what the exact
request was you received.
--
Rik Wasmus
Closed Thread