Christian Felix
Christian Felix

Reputation: 673

Xpath fetching node by attributes

This should be rather a simple task, but for some reasons a part of my xml file hasn't been read properly...

This is the XML Section in question:

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

Now, i want to fetch the Node by following code:

 $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...

What is the difference? Thanks in advance

Upvotes: 1

Views: 56

Answers (1)

splash58
splash58

Reputation: 26153

Xpath is case-sensitive. Use and instead of 'AND'

demo

Upvotes: 1

Related Questions