tags:

views:

31

answers:

1

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

Best regards Christoph

A: 

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]
Dimitre Novatchev
thanks, thats working fine.
chmav