Reputation: 5512
I've this xml
<root>
<node1>
<node2>xxx</node2>
</node1>
...
<node1>
<node2>yyy ABC yyy</node2>
</node1>
...
<node1>
<node2>zzz</node2>
</node1>
</root>
I want to get node1 that has a node2 containing the text ABC.
Is it possible to achieve this using XPath?
Upvotes: 1
Views: 182
Reputation: 2737
I tried using this XPath Tester here: http://www.yetanotherchris.me/home/2010/6/7/online-xpath-tester.html. Does this work for you?
//node1/node2[contains(.,"ABC")]
Upvotes: 0
Reputation: 15816
I'm pretty sure this will do the trick:
node1[node2[contains(text(),"ABC")]]
EDIT: Tested, seems to work.
Upvotes: 5