我正在尝试阅读以下内容并在其中选择一个节点
<ns1:OrderInfo xmlns:ns1="http://xxxxxx Some URL XXXX">
<pricing someAttrHere>
<childnodes>
</pricing>
</ns1:OrderInfo>
.
XmlDocument document = new XmlDocument();
document.Load(Server.MapPath("order.xml"));
XmlNamespaceManager manager = new XmlNamespaceManager(document.NameTable);
manager.AddNamespace("ns1", "http://xxxxxx Some URL XXXX");
query = "/ns1:OrderInfo/pricing";
XmlNodeList nodeList = document.SelectNodes(query);
但它总是给“需要命名空间管理器或XsltContext”
正如你在上面看到的,我使用XmlNamespaceManager添加命名空间,但仍然给出错误,请帮助
您还需要使用XmlNamespaceManager:
XmlNodeList nodeList = document.SelectNodes(query, manager);