How to process XML sernt via POST?
- by John Conde
I'm receiving XML sent via POST. Naturally I need to parse this XML to get at the goodies it holds for me. However, when I receive the XML is seems that PHP is parsing it like a query string.
For example, this xml:
<?xml version="1.0" encoding="utf-8"?>
<ForgotPassword>
<version>1.0</version>
<authentication>
<login>myresllerid</login>
<apikey>1234567890abcdef</apikey>
</authentication>
<parameters>
<emailAddress>[email protected]</emailAddress>
</parameters>
</ForgotPassword>
Becomes this (from print_r($_REQUEST)):
Array
(
[
<?xml_version] => "1.0" encoding="utf-8"?>
<IDCForgotPassword>
<version>1.0</version>
<authentication>
<login>myresllerid</login>
<apikey>1234567890abcdef</apikey>
</authentication>
<parameters>
<emailAddress>[email protected]</emailAddress>
</parameters>
</IDCForgotPassword>
)
You can see the XML is being broken up at the first equals sign (=) in the XML into a key/value pair.
How do I avoid this?