这个XML挺标准的啊 用XmlDocument

解决方案 »

  1.   

    var xn = xdoc.SelectSingleNode("root").SelectNodes("i");
    var result = "";
    foreach (var item in xn)
    {
    XmlElement xe = (XmlElement)item;
    result += xe.GetAttribute("d")
    }
    现在要获取P怎么弄啊?
      

  2.   


                System.Xml.Linq.XDocument doc = System.Xml.Linq.XDocument.Load("e:\\1.txt");
                foreach (System.Xml.Linq.XElement item in doc.Descendants("i"))
                {
                    MessageBox.Show(item.Attribute("d").Value);
                }
                foreach (System.Xml.Linq.XElement item in doc.Descendants("c"))
                {
                    MessageBox.Show(item.Attribute("p").Value);
                }
      

  3.   


    XmlDocument docu = new XmlDocument();
                docu.LoadXml(File.ReadAllText("c://1.txt"));
                foreach (XmlNode item in docu.ChildNodes.Item(0).ChildNodes)
                {
                    if (item.Name == "i")
                    {
                        Console.WriteLine(item.Attributes[0].Value + "," + item.Attributes[1].Value);
                    }
                }晕 楼上这几个人写代码速度太快了
      

  4.   


    XmlDocument docu = new XmlDocument();
                docu.LoadXml(File.ReadAllText("c://1.txt"));
                foreach (XmlNode item in docu.ChildNodes.Item(0).ChildNodes)
                {
                    if (item.Name == "i")
                    {
                        Console.WriteLine(item.Attributes[0].Value + "," + item.FirstChild.Attributes[2].Value);
                    }
                }弄成了-1了