【发布时间】:2016-02-25 10:13:36
【问题描述】:
我有一个包含以下标签的 xml 文件。
<ClinicalDocument xmlns:ext="http://ns.electronichealth.net.au/Ci/Cda/Extensions/3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:hl7-org:v3">
现在我必须阅读这个并将属性值写入一个字符串。
现在我正在使用以下代码。
XmlDocument xDocument = new XmlDocument();
xDocument.Load(@"c:\Test.xml");
System.Text.StringBuilder ClinicalDocument = new System.Text.StringBuilder();
ClinicalDocument.Append("<ClinicalDocument xmlns:ext=" + xDocument.SelectSingleNode("/ClinicalDocument/@xmlns:ext").Value + " xmlns:xsi=" + xDocument.SelectSingleNode("/ClinicalDocument/@xmlns:xsi").Value + " xmlns=" + xDocument.SelectSingleNode("/ClinicalDocument/@xmlns").Value + ">");
Response.Write(ClinicalDocument);
但其抛出异常“需要命名空间管理器或 XsltContext。此查询具有前缀、变量或用户定义的函数。”
请提出我做错了什么或有其他选择。我对 XML 完全陌生。
【问题讨论】:
标签: c# xml c#-4.0 xml-parsing