xpath 返回所有非空白文本节点不是`a`、`style` 或`script` 的后代 [英] xpath return all non-blank text nodes not descendant of `a`, `style` or `script`

查看:18
本文介绍了xpath 返回所有非空白文本节点不是`a`、`style` 或`script` 的后代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么表达式会选择所有文本节点:

What expression would select all text nodes which are:

  • 空白
  • 不是a,还是scriptstyle?
  • not blank
  • not inside a, or script or style?

推荐答案

这应该可以,假设not inside"意味着文本节点不应该是a"或script"或style"的后代元素.如果不在里面"仅意味着不应该是孩子,则使用 parent::a 等而不是祖先::a.

This should do, assuming "not inside" means the text node is not supposed to be a descendant of an "a" or "script" or "style" element. If "not inside" only means not supposed to be a child then use parent::a and so on instead of ancestor::a.

//text()[normalize-space() and not(ancestor::a | ancestor::script | ancestor::style)]

这篇关于xpath 返回所有非空白文本节点不是`a`、`style` 或`script` 的后代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆