开发者

Xpath: Select only non-nested pre tags

Can anyone help me with a xpath selector to select all the pre tags with开发者_JAVA技巧in a page, but only if they are not within another pre tag? (even if multiple levels deep)

It would be awesome if this could all be done within one selector, rather than just selecting all pre tags and breaking if they have pre as a parent.


Like this? //pre[not(ancestor::pre)]


Or for completeness, in XPath 2.0

//pre except //pre//pre


Try:

//pre[not(ancestor::pre)]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜