ancestor::foo[bar[@attr=\"val\"]]
I thought this would work, but it\'s not. I need to find the nearest foo element going up in the tree tha
foo
This should work:
//*[ancestor::foo[bar[@attr="val"]]]
or alternatively
root/foo/bar[ancestor::foo[bar[@attr="val"]]]
matches the second element