我将收到通过POST发送的XML。自然地,我需要解析这个XML以获取其中的有用信息。然而,当我接收到XML时,PHP似乎像解析查询字符串一样解析它。
例如,这个XML:
<?xml version="1.0" encoding="utf-8"?>
<ForgotPassword>
<version>1.0</version>
<authentication>
<login>myresllerid</login>
<apikey>1234567890abcdef</apikey>
</authentication>
<parameters>
<emailAddress>joesmith@example.com</emailAddress>
</parameters>
</ForgotPassword>
变成这样(从
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>joesmith@example.com</emailAddress>
</parameters>
</IDCForgotPassword>
)
你可以看到XML在第一个等号(=)处被分成了键值对。
我应该如何避免这种情况?