Reputation: 85
I've something like:
<a>
<b>
<c>
<d name='pa'/>
<d name='pb'/>
</c>
</b>
</a>
<a>
<b>
<c>
<d name='pc'/>
<d name='pb'/>
</c>
</b>
</a>
with xpath how can I retrieve the element parent a which has both attribute name=pa
and name=pc
of tag d?
I tried with this one but it doesnt work:
(/a/b/c/d[@name='pa']) and (/a/b/c/d[@name='pc'])
but it just outputs Boolean='true'
Upvotes: 2
Views: 913
Reputation: 52665
Try to use
//a[.//d[@name="pa"] and .//d[@name="pb"]]
which should return your desired output
Upvotes: 1