Selecting Comments by their inner xml in xpath/xsl

那年仲夏 提交于 2019-12-07 08:22:11

问题


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


回答1:


This

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

seems to work.




回答2:


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



来源:https://stackoverflow.com/questions/1759672/selecting-comments-by-their-inner-xml-in-xpath-xsl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!