So, I am trying to parse the following XML document using C # using System.XML:
<root xmlns:n="http://www.w3.org/TR/html4/"> <n:node> <n:node> data </n:node> </n:node> <n:node> <n:node> data </n:node> </n:node> </root>
In every XPath treaty with namespaces, I need to do the following:
XmlNamespaceManager mgr = new XmlNamespaceManager(xmlDoc.NameTable); mgr.AddNamespace("n", "http://www.w3.org/1999/XSL/Transform");
And after I add the code above, the request
xmlDoc.SelectNodes("/root/n:node", mgr);
It works fine, but returns nothing. Following:
xmlDoc.SelectNodes("/root/node", mgr);
returns two nodes if I modify the XML file and delete the namespaces, so everything else seems to be configured correctly. Any idea why this works, not with namespaces?
Thanks a lot!
c # xml xpath
Vercinegetorix
source share