一个简单的xml,如下所示:
<?xml version="1.0" encoding="GBK"?>@H_502_5@
<Document@H_502_5@>@H_502_5@
<ChiefComplaint@H_502_5@>@H_502_5@
<![CDATA[右眼视力进行性下降2年余]]>@H_502_5@
</ChiefComplaint@H_502_5@>@H_502_5@
</Document@H_502_5@>@H_502_5@
我们该如何读取“
private int ReadXml()
{
string responseInfo = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>@H_502_5@"
+ @"<Document@H_502_5@>@H_502_5@
<ChiefComplaint@H_502_5@>@H_502_5@
<![CDATA[右眼视力进行性下降2年余]]>@H_502_5@
</ChiefComplaint@H_502_5@>@H_502_5@
</Document@H_502_5@>@H_502_5@";
XmlDocument doc = new XmlDocument();
doc.LoadXml(responseInfo);
string xpathChiefComplaint = "/Document/ChiefComplaint";
XmlNode xnChiefComplaint = doc.SelectSingleNode(xpathChiefComplaint);
string nodeValue = xnChiefComplaint.InnerText;
}
以上代码就可以得到nodeValue 是“右眼视力进行性下降2年余”。