C#XML格式字符串取節點數據


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數據


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM