C # XML parsing values

Source: Internet
Author: User

String

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> ";

Conversion format
var xdoc = new XmlDocument ();

Parse an XML
Xdoc. LOADXML (result);
XmlNode xnode = Xdoc. selectSingleNode ("speed/is_success");//Take the value of the Is_success node
string is_success = Xnode.innertext;
Info. ADD ("Is_success", Xnode.innertext);
T means success F means failure
if (is_success = = "T")
{
XmlNode XmlNode = Xdoc. selectSingleNode ("Speed/response/protocol");//Take the value of the Protocol node
XmlNodeList xmlList = xmlnode.childnodes;//Get node

Loop node
foreach (XmlElement item in xmlList)
{
Info. ADD (item. Name, item. InnerText);
}
}

C # XML parsing values

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.