XML在不同机器上的解析方式不同

时间:2013-06-10 06:47:35

标签: php xml simplexml

这是我的输入xml

   <app appid="{C38B7539}" lang="en">
      <updatecheck/>
   </app>

通过以下php

进行解析
$xmlObj = simplexml_load_string($xmlStr);
if ($xmlObj === false) {
    // log errors
    return;
}
print_r($xmlObj);

Windows上的输出(有故障)

[app] => SimpleXMLElement Object
    (
        [@attributes] => Array
            (
                [appid] => {C38B7539}
                [lang] => en
            )

        [0] => SimpleXMLElement Object   <-- Note the 0 instead of updatecheck
            (
            )
    )

linux上的输出(正确)

[app] => SimpleXMLElement Object
    (
        [@attributes] => Array
            (
                [appid] => {C38B7539}
                [lang] => en
            )

        [updatecheck] => SimpleXMLElement Object
            (
            )
    )

结果array_key_exists('updatecheck', $xmlObj)在linux下返回true,在Windows下返回false

如何修复我的解析器代码以使其在Windows下运行?

0 个答案:

没有答案
相关问题