XPathSelectElement always returns null

后端 未结 4 727
借酒劲吻你
借酒劲吻你 2020-12-01 21:00

Why is this Xpath not working using XDocument.XPathSelectElement?

Xpath:

//Plugin/UI[1]/PluginPageCategory[1]/Page[1]/Group[1]/CommandRef[2]
<         


        
4条回答
  •  旧巷少年郎
    2020-12-01 21:06

    This should probably be a comment on @Cumbayah's post, but I can't seem to leave comments on anything.

    You are probably better off using something like this instead of using XmlReader to get the nametable.

    var xml = ... XML from your post ...;
    var myXDocument = XDocument.Parse(xml);
    var namespaceManager = new XmlNamespaceManager(new NameTable());
    namespaceManager.AddNamespace("prefix", "http://www.MyNamespace.ca/MyPath");
    
    var result = ...;
    

提交回复
热议问题