473,408 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Reading XML with PHP

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.

Mar 16 '07 #1
4 2670
Am 16 Mar 2007 02:47:32 -0700 schrieb Aggelos:
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
Mar 16 '07 #2
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.

Mar 16 '07 #3
>
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 ;)

Mar 16 '07 #4
Rik
On Fri, 16 Mar 2007 12:26:31 +0100, Aggelos <dj*****@gmail.comwrote:
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
Mar 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andy | last post by:
Hi, In the code below (not pretty I know but it's an early version :-P) I'm having problems reading the data object back in. If I move the reading code to immediately after the section where it...
6
by: Raymond Hettinger | last post by:
Found in a pamphlet at a pre-school: --------------------------------------- Reading improves vocabulary Reading raises cultural literacy through shared knowledge Reading develops writing skills...
4
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # to open a file and write to file # do f=open('xfile.txt','w') # this creates a file "object" and name it f. # the second argument of open can be
24
by: Hendrik Schober | last post by:
Hi, I have a 'std::istream' and need to read its whole contents into a string. How can I do this? TIA; Schobi
19
by: Lionel B | last post by:
Greetings, I need to read (unformatted text) from stdin up to EOF into a char buffer; of course I cannot allocate my buffer until I know how much text is available, and I do not know how much...
4
by: Oliver Knoll | last post by:
According to my ANSI book, tmpfile() creates a file with wb+ mode (that is just writing, right?). How would one reopen it for reading? I got the following (which works): FILE *tmpFile =...
6
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am...
3
by: Nick | last post by:
I have found a class that compresses and uncompresses data but need some help with how to use part of it below is the deflate method which compresses the string that I pass in, this works OK. At...
9
by: Mike Reed | last post by:
I must be having a "senile" day! I cannot recall, nor get to work, code to read a cookie's expiration date/time in an ASP page/VBScript. What am I missing? *** Sent via Developersdex...
4
by: Gaijinco | last post by:
I had a file named nap.in which looks like this: 4 10:00 12:00 Lectures 12:00 13:00 Lunch, like always. 13:00 15:00 Boring lectures... 15:30 17:45 Reading 4 10:00 12:00 Lectures 12:00 13:00...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.