开发者

Select Comment with xPath by Comment-Text

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜