views:

369

answers:

2

Hi,

Given the following xml document

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

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

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

However i'd like to select a comment where the inner xml is "Comment2".

Any ideas?

Thanks

Dave

+6  A: 

This

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

seems to work.

Corey Porter
+1  A: 

maybe this would work: /root/comment()[2]

Andrei
That would work in above example.. However i kept the example simple... It will be in a much larger XML document.. so that's why i needed to be able to select by inner XML..
CraftyFella