Selecting comments by their internal xml in xpath / xsl

Given the following xml document

<root> <childnode0/> <childnode2/> <!--Comment1--> <childnode3/> <childnode4/> <!--Comment2--> </root> 

I know xpath to select all comments at a specific level in xsl

 string xPath = "/root/comment()"; 

However, I would like to select a comment where the internal xml is "Comment2".

Any ideas?

thanks

Dave

+4
source share
2 answers

it

 /root/comment()[.='Comment2'] 

seems to work.

+11
source

perhaps this will work: /root/comment()[2]

+1
source

All Articles