I am trying to find a way to search for a string within nodes, but excluding ythe content of some subelements of those nodes. Plain and simple, I want to search for a string in
I want to search for a string in paragraphs of a text, excluding the footnotes which are children elements of the paragraphs
An XPath 1.0 - only solution:
Use:
//p//text()[not(ancestor::footnote) and contains(.,'text')]
Against the following XML document (obtained from yours but added p
s within a footnote
to make this more interesting):
My text starts here/
Then it goes on there
It's not a very long text!
text
this XPath expression selects exactly the wanted text node:
My text starts here/