I'm looking for the right xpath expression to select all nodes whose nearest ancestor have the proper attribute value, and not to select those whose nearest ancestor have an explicit 'don't select' attribute value. Visually explained: for each branch, follow its path to the root, and the first time a certain attribute is encountered should decide if it is in the selection or not.
<xyz select="yes">
<blabla>this one's in</blabla>
<qwerty select="no">this one's out
<foobar>out please!</foobar>
<gettingoutofnames select="yes">in again!</gettingoutofnames>
</qwerty>
</xyz>
Example can occur anywhere in the XML structure.
Names of elements can be anything. 'select="yes"' and 'select="no"' can follow in any order, but the deepest one is decisive its descendants.
I'm thinking something like this:
//*[@select="yes"]//ancestor::*[not(@select="no")]
but that doesn't catch it all. Any help is appreciated!