标签:
//字符串
string result = "<?xml version=\"1.0\" encoding=\"utf-8\"?><speed><is_success>T</is_success><response><protocol><partner>123456</partner><sign>123456</sign><sign_type>md5</sign_type><timestamp>20090707122322</timestamp><version>1.0</version></protocol></response></speed>";
//转换格式
var xdoc = new XmlDocument();
//解析一个 XML
xdoc.LoadXml(result);
XmlNode xNode = xdoc.SelectSingleNode("speed/is_success");//取is_success节点的值
string is_success = xNode.InnerText;
info.Add("is_success", xNode.InnerText);
//T表示成功 F表示失败
if (is_success == "T")
{
XmlNode xmlNode = xdoc.SelectSingleNode("speed/response/protocol");//取protocol节点的值
XmlNodeList xmlList = xmlNode.ChildNodes;//获取节点
//循环节点
foreach (XmlElement item in xmlList)
{
info.Add(item.Name, item.InnerText);
}
}
标签:
原文地址:http://www.cnblogs.com/chj929555796/p/5477275.html