【发布时间】:2017-10-24 04:24:28
【问题描述】:
我有以下 XML:
<myfile:bookstore>
<myfile:books>
<myfile:book> Book 1</myfile:book>
<myfile:book> Book 2</myfile:book>
</myfile:books>
</myfile:bookstore>
以下代码选择<myfile:books>节点:
XmlNamespaceManager nsmgr = new
XmlNamespaceManager(el.OwnerDocument.NameTable);
nsmgr.AddNamespace("myfile",
el.OwnerDocument.DocumentElement.NamespaceURI);
var node = el.SelectSingleNode(@"/myfile:bookstore/myfile:books", nsmgr);
在节点名称为myfile:boOkS 或myfile:BOOKS 不区分大小写之前,如何使这个工作?
另一个问题是我的 namespaceManager 吗?能不能简单点?
【问题讨论】:
-
如果我想要的节点是这样的示例:
OR 我希望它适用于所有情况
标签: c# xml xpath xml-namespaces selectsinglenode