Selecting Comments by their inner xml in xpath/xsl

2019-05-03 16:16发布

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

2条回答
Ridiculous、
2楼-- · 2019-05-03 16:33

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

查看更多
贼婆χ
3楼-- · 2019-05-03 16:38

This

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

seems to work.

查看更多
登录 后发表回答