xpath return all non-blank text nodes not descendant of `a`, `style` or `script`

后端 未结 3 1445
梦毁少年i
梦毁少年i 2020-12-06 10:07

What expression would select all text nodes which are:

  • not blank
  • not inside a, or script o
3条回答
  •  执念已碎
    2020-12-06 10:41

    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)]
    

提交回复
热议问题