Example, I have an XML doc like this
a[@class="wrong]
...
b
c
d
...
b
c <= this one
I would like to select the second //b/c without taking the //b/c from the first part with @class="wrong". And there are some unknown node between unwanted node and the //b/c. And I do not know wich is the exact markup with non desired class.
So I try //*[not(contains(@class,'wrong'))]/b/c
but it doesn't work because if there is at least one node in '...' without this class, the first b/c is also returned.
Use:
//b[not(ancestor::*[contains(@class,'wrong')])]/c
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.