xpath check if document contains text



I want to get all XML nodes that contains specified text. For example, when searching for text "aa" in document:



<book>
<content>
aaaaaaa
<markup/>
bbbbbb
</content>
<author>
aabbcc
</author>
</book>


I should get nodes content and author.


I was trying to use XPath "//*[contains(text(), 'aa')]" but it fails when node has some subnodes that split text (like markup which splits content in above example).


Do you know how to solve that problem?


No comments:

Post a Comment