how to use XPath with XDocument?

后端 未结 3 1907
悲哀的现实
悲哀的现实 2020-11-27 03:39

There is a similar question, but it seems that the solution didn\'t work out in my case: Weirdness with XDocument, XPath and namespaces

Here is the XML I am working

3条回答
  •  一向
    一向 (楼主)
    2020-11-27 04:05

    you can use the example from Microsoft - for you without namespace:

    using System.Xml.Linq;
    using System.Xml.XPath;
    var e = xdoc.XPathSelectElement("./Report/ReportInfo/Name");     
    

    should do it

提交回复
热议问题