我有一个带有多个名称空间的 XML 文件。但我无法从任何节点获取值/文本。
<?xml version="1.0" encoding="UTF-8"?>
<!--XML file created by Microsoft Dynamics C5-->
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2"
xmlns:ccts="urn:un:unece:uncefact:documentation:2"
xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2">
<cbc:UBLVersionID schemeAgencyID="320" schemeAgencyName="urn:oioubl:id:profileid-1.1">2.0</cbc:UBLVersionID>
<cbc:CustomizationID>OIOUBL-2.02</cbc:CustomizationID>
<cbc:ProfileID schemeID="urn:oioubl:id:profileid-1.2" schemeAgencyID="320">Procurement-BilSim-1.0</cbc:ProfileID>
<cbc:ID>88481</cbc:ID>
<cbc:IssueDate>2012-05-21</cbc:IssueDate>
<cbc:InvoiceTypeCode listID="urn:oioubl:codelist:invoicetypecode-1.1" listAgencyID="320">380</cbc:InvoiceTypeCode>
<cbc:DocumentCurrencyCode>DKK</cbc:DocumentCurrencyCode>
<cbc:AccountingCost></cbc:AccountingCost>
<cac:OrderReference>
<cbc:ID>ZZ</cbc:ID>
<cbc:SalesOrderID>36433</cbc:SalesOrderID>
<cbc:IssueDate>2012-05-21</cbc:IssueDate>
</cac:OrderReference>
</Invoice>
我正在尝试读取一些节点,但我不能。这是一个例子。
XmlDocument doc = new XmlDocument();
doc.Load(@"C:\temp\88481.xml");
XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable);
manager.AddNamespace("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2");
manager.AddNamespace("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2");
manager.AddNamespace("qdt", "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2");
manager.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
manager.AddNamespace("udt", "urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2");
manager.AddNamespace("ccts", "urn:un:unece:uncefact:documentation:2");
manager.AddNamespace("ext", "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2");
manager.AddNamespace("", "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2");
XmlNodeList list = doc.SelectNodes("//Invoice/cbc:ID", manager);
但是节点列表没有元素?