How to process XML sernt via POST?
Posted
by John Conde
on Stack Overflow
See other posts from Stack Overflow
or by John Conde
Published on 2010-05-10T13:59:40Z
Indexed on
2010/05/10
14:04 UTC
Read the original article
Hit count: 268
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?
© Stack Overflow or respective owner