开发者

Select Comment with xPath by Comment-Text

开发者 https://www.devze.com 2022-12-26 15:15 出处:网络
How can I select the next node after an defined comment? I know the text of the comment and need the next nodes.

How can I select the next node after an defined comment? I know the text of the comment and need the next nodes.

Bes开发者_如何学Got regards Christoph


Supposing the comment is a child of the current node, and the comment's text is "comment-text", then the following XPath expression selects the first element (sibling) that follows the comment node:

comment()[. = 'comment-text'][1]/following-sibling::*[1]

If we want the following element to be selected (regardless if it is sibling of the comment or not), the corresponding XPath expression is:

comment()[. = 'comment-text'][1]/following::*[1]
0

精彩评论

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

关注公众号