Can't get XmlDocument.SelectNodes to retrieve any of my nodes?

前端 未结 4 1913
迷失自我
迷失自我 2020-12-28 08:09

I\'m trying to parse an XML document. The document in question is an AppxManifest file.

An example document looks like this:



        
4条回答
  •  情话喂你
    2020-12-28 09:14

    You have to use xml namespace specifically to select them. consider

    "//*[local-name()='Applications']/*[local-name()='Application']"    
    

    in your case this code may also work well:

    var doc = new XmlDocument();
    doc.LoadXml(xml);
    var nsmgr = new XmlNamespaceManager(doc.NameTable);
    nsmgr.AddNamespace("a", "http://schemas.microsoft.com/appx/2010/manifest");
    var nodes = doc.SelectNodes("//a:Applications/a:Application",nsmgr);
    

提交回复
热议问题