Reputation: 916
So, here is an example of the XML
<a>
<b id=0>
<c k=1/>
</b>
<b id=1>
<c k=2/>
</b>
</a>
I need to find all pairs of c where the K value is the same, and report the id of b ... I tried loops, following::b , all not working ... so, any suggestions?
Upvotes: 1
Views: 677
Reputation: 2814
Try:
//b[c/@k = following-sibling::b/c/@k]
With:
<a>
<b id="0">
<c k="1"/>
</b>
<b id="1">
<c k="2"/>
</b>
<b id="2">
<c k="2"/>
</b>
<b id="3">
<c k="1"/>
</b>
</a>
It will give:
<b id="0">
<c k="1"/>
</b>
-----------------------
<b id="1">
<c k="2"/>
</b>
Upvotes: 2