Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
531 views
in Technique[技术] by (71.8m points)

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

What expression would select all text nodes which are:

  • not blank
  • not inside a, or script or style?
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use:

//*[not(self::a or self::script or self::style)]/text()[normalize-space()]

Not only is this expression shorter than the one in the currently accepted answer, but it also may be much more efficient.

Do note that the expression doesnt use any (back/up)-ward axes at all.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...