How to get xpath from an XmlNode instance

后端 未结 14 1109
难免孤独
难免孤独 2020-11-30 18:17

Could someone supply some code that would get the xpath of a System.Xml.XmlNode instance?

Thanks!

14条回答
  •  猫巷女王i
    2020-11-30 18:52

    There's no such thing as "the" xpath of a node. For any given node there may well be many xpath expressions which will match it.

    You can probably work up the tree to build up an expression which will match it, taking into account the index of particular elements etc, but it's not going to be terribly nice code.

    Why do you need this? There may be a better solution.

提交回复
热议问题