How to select an element whose ascendant is not a certain tag?

时间:2018-07-25 04:25:24

标签: xpath

I'd like to select elements of strong. But I want to select the ones not in h3. Does anybody know how to do in xpath? Thanks.

<h3><sub><strong>abc</strong></sub></h3>

1 个答案:

答案 0 :(得分:0)

You’re looking for the ancestor:: axis.

//strong[not(ancestor::h3)]