如何解析xml文件

来源:互联网 发布:lumia2520能用什么软件 编辑:程序博客网 时间:2024/05/21 18:48

如何解析xml文件

举报|2011-01-29 09:11zhg324ll | 分类:网站使用 | 浏览28228次
<?xml version="1.0" encoding="GB2312" ?><num n="0">         (数组长度)<pdr t="0" Q="0.00"/><pdr t="1" Q="14.22"/><pdr t="2" Q="72.04"/><pdr t="3" Q="174.34"/><pdr t="4" Q="383.93"/><pdr t="5" Q="541.41"/>
希望能给出详细方法  谢谢
2011-01-29 10:58提问者采纳
string xmlPath = "Demo.xml"XmlDocument _XmlDoc = new XmlDocument();_XmlDoc.Load(xmlPath);//数组长度string num =  "";Dictionary<string, string> xmlData = new Dictionary<string, string>();foreach (XmlNode node in _XmlDoc.ChildNodes){      if(node.Name == "num")           num = node.Attributes["n"].Value;      if(node.Name == "pdr")           xmlData.Add(node.Attributes["t"].Value,node.Attributes["Q"].Value);}//至此XML解析完毕字典里保存pdr数据num 变量保存数组长度
0 0
原创粉丝点击