码迷,mamicode.com
首页 > 其他好文 > 详细

遍历简单XML节点

时间:2017-07-12 10:11:26      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:foreach   each   app   one   XML   version   att   inner   weight   

原文发布时间为:2009-08-26 —— 来源于本人的百度文章 [由搬家工具导入]

<?xml version="1.0" encoding="gb2312" ?>
<root>
<name id="1">sdfsdf</name>
<name id="2">sdgsd</name>
<name id="3">sdf<name>

</root>

string url = Server.MapPath("../XML/zone.xml");
        System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
        xdoc.Load(url);
        System.Xml.XmlNodeList nodeList = xdoc.SelectNodes("root/name");
        foreach (System.Xml.XmlNode node in nodeList)
        {
            string strID = node.Attributes["id"].InnerText;
            if (strID=="1")
            {
                Response.Write(node.InnerXml);
            }

        }

遍历简单XML节点

标签:foreach   each   app   one   XML   version   att   inner   weight   

原文地址:http://www.cnblogs.com/handboy/p/7153355.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!