这是我输入的xml
<app appid="{C38B7539}" lang="en">
<updatecheck/>
</app>
Run Code Online (Sandbox Code Playgroud)
通过以下php解析
$xmlObj = simplexml_load_string($xmlStr);
if ($xmlObj === false) {
// log errors
return;
}
print_r($xmlObj);
Run Code Online (Sandbox Code Playgroud)
Windows上的输出(故障)
[app] => SimpleXMLElement Object
(
[@attributes] => Array
(
[appid] => {C38B7539}
[lang] => en
)
[0] => SimpleXMLElement Object <-- Note the 0 instead of updatecheck
(
)
)
Run Code Online (Sandbox Code Playgroud)
linux上的输出(正确)
[app] => SimpleXMLElement Object
(
[@attributes] => Array
(
[appid] => {C38B7539}
[lang] => en
)
[updatecheck] => SimpleXMLElement Object
(
)
)
Run Code Online (Sandbox Code Playgroud)
结果在linux 下和windows下array_key_exists('updatecheck', $xmlObj)
返回.true
false
如何修复我的解析器代码以使其在Windows下工作?
归档时间: |
|
查看次数: |
68 次 |
最近记录: |