Xpath 通过属性获取节点

Xpath fetching node by attributes

这应该是一个相当简单的任务,但是由于某些原因,我的 xml 文件的一部分没有被正确读取...

这是有问题的 XML 部分:

<MTX>
...
<MoClass code=".0" modi="XYZ">
.....
</MoClass>
......
</MTX>

现在,我想通过以下代码获取节点:

 $xml = simplexml_load_file(filename)

 //this fails due to invalid predicate...
 $xml->xPath('//MoClass[@code=".0" AND @modi="XYZ"]');

 //but when i reverse the sequence of attributes 
 $xml->xPath('//MoClass[@modi="XYZ" AND @code=".0"]');
 //then it works as expected and the node may be processed further...

有什么区别? 提前致谢

Xpath 区分大小写。使用 and 而不是 'AND'

demo