How to specify a condition on all path elements in XPath?

Viewed 94

Here is my XML:

<a>
  <a>
    <a stop="">
      <a>
        <b/>
      </a>
    </a>
  </a>
</a>

I need to select element <b> if the path to it doesn't have <a> with @stop. It should be something like this (assume I'm already staying at some <a> in the tree):

a//[not(@stop)]b
1 Answers

select element <b> if the path to it doesn't have <a> with @stop

I would read that as:

//b[not(ancestor::a/@stop)]
Related