[thelist] Retrieving Post data
Jay Blanchard
jay.blanchard at niicommunications.com
Tue Jan 18 07:09:10 CST 2005
[snip]
Suppose a user agent sends the following HTTP post request:
<!-- start (not part of HTTP message)
POST /listener.php HTTP/1.0
Content-Type: text/xml; charset=iso_8859-1
Accept: text/xml
Accept-Charset: utf-8, iso_8859-1
Content-Length: 190
<?xml version="1.0"?>
<XML_DATA>
<Fields>
<ID type="CHAR">abcde</ID>
<NAME type="CHAR">Test Data</NAME>
<EFFDATE type="DATE">01/01/2005</EFFDATE>
</Fields>
</XML_DATA>
end -->
How do I read the embedded xml data in PHP? I tried looking at
$_REQUEST and it's not there.
[/snip]
You need to RTFM about XML and PHP http://www.php.net/xml as well as
understanding the various external variables, such as POST
http://us4.php.net/variables.external. The illustration that you provide
does not have the XML contained in any of the $_REQUEST variables, so
you really do not have access to it.
Typically XML data is read from a file and then parsed. You can also
read XML data via a socket http://us4.php.net/manual/en/ref.sockets.php
If you wanted to you could place all of the XML data in a variable in
the POSTing entity, like this...
$xmlVariable = "<?xml version=\"1.0\"?>
<XML_DATA>
<Fields>
<ID type="CHAR">abcde</ID>
<NAME type="CHAR">Test Data</NAME>
<EFFDATE type="DATE">01/01/2005</EFFDATE>
</Fields>
</XML_DATA>";
Send the post to the receveing entity and ...
echo $_POST['xmlVariable'];
But that is highly inefficient and may cause you other problems.
More information about the thelist
mailing list