Find element all of whose children have a given value

Posted by cru3l on Stack Overflow See other posts from Stack Overflow or by cru3l
Published on 2010-06-14T23:32:56Z Indexed on 2010/06/15 0:52 UTC
Read the original article Hit count: 254

Filed under:
|
|

for example, i have this xml

<elements>
<a>
     <b>6</b> 
     <b>5</b>
     <b>6</b>
</a>
<a>
     <b>5</b>
     <b>5</b>
     <b>6</b>
</a>
<a>
     <b>5</b>
     <b>5</b>
     <b>5</b>
     <b>5</b>
</a>
</elements>

i need a xpath query, which must return me parent tag, only if all its children are equal to 5 (a[3] in this case). Something like that

//b[text()="5"]/..

but with check of all children's tags. Please note that number of children tags can be different from node to node.

It's possible with only xpath query?

thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml