How to read XML in C# using Xpath

后端 未结 3 746
耶瑟儿~
耶瑟儿~ 2020-12-06 12:18

I have this XML




        
3条回答
  •  [愿得一人]
    2020-12-06 12:51

    SKUsDetails is defined in http://tempuri.org/ namespace. You can use this code to select SKUsDetails using XPath:

    var doc = XDocument.Load("1.xml");
    
    var mgr = new XmlNamespaceManager(doc.CreateReader().NameTable);
    mgr.AddNamespace("a", "http://tempuri.org/");
    
    var node = doc.XPathSelectElement("//a:SKUsDetails", mgr);
    

    To select SKUDetails use: //a:SKUsDetails/a:SKUDetails

提交回复
热议问题