Linq to xml 小例

static void Main(string[] args)
        {
            string strXml = @"<?xml version='1.0' encoding='utf-8' ?>
                    <root>
                    <MerchantID>1000</MerchantID>
                    <OrderID>mzo20151208162758</OrderID>
                    <Status>1</Status>
                    <TranInfo>成功</TranInfo>
                    <CardType>000701</CardType>
                    <Value>10</Value>
                    <Datetime>20151208171038</Datetime>
                    <TranOrder>201512081634311000855</TranOrder>
                    <Attach/>
                    <Sign>FB4D2101E05BC3822C089B09E0586086</Sign>
                    </root>
                    ";

XmlDocument xx = new XmlDocument();
            xx.LoadXml(strXml);
            XmlNode xxNode = xx.SelectSingleNode("/root/Value");
            //Console.WriteLine(xxNode.InnerText);
            foreach (XmlNode xxNode2 in xxNode.ChildNodes)
            {
                if (xxNode2.Name == "Status")
                {
                    Console.WriteLine(xxNode2.Name + "---" + xxNode2.InnerText);
                }
            }
            Console.ReadKey();
        }

上一篇:Eclipse个人规范化设置


下一篇:jQuery Ajax Post Data Example