XML格式的字符串:
<xml><return_code><![CDATA[{0}]]></return_code><return_msg><![CDATA[{1}]]></return_msg></xml>
就像上面例子格式的字符串,如果參數0中放入數據SUCCESS,如何取得SUCCESS節點數據
{0}這個節點一般都會存取敏感數據public static string Deserialize(string xml)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
string xpathChiefComplaint = "/xml/return_code";
XmlNode xnChiefComplaint = doc.SelectSingleNode(xpathChiefComplaint);
string nodeValue = xnChiefComplaint.InnerText;
return nodeValue;
}
如上代碼方法就能取到節點{0}中的SUCCESS數據