How to select all leaf nodes using XPath expression?

后端 未结 4 1427
傲寒
傲寒 2020-11-28 05:25

I believe it\'s possible but couldn\'t figure out the syntax. Something like this:

xmlNode.SelectNodes(\"//*[count(child::*) <= 1]\")

bu

4条回答
  •  误落风尘
    2020-11-28 06:08

    Why less or equal to 1 ?

    xmlNode.SelectNodes("//*[count(child::*) = 0]")

    Make tests etc at this site http://www.whitebeam.org/library/guide/TechNotes/xpathtestbed.rhtm

    Pretty helpful ..

提交回复
热议问题