本帖最后由 O7110650504 于 2011-08-08 10:04:07 编辑

解决方案 »

  1.   

    <?xml version="1.0" encoding="utf-8"?>
    <Resp>
      <H>
        <Ver>版本号</Ver>
        <Sc>状态码</Sc>
        <Msg>返回消息</Msg>
      </H>
    </Resp>
    其次,你可以用一下代码取得你想要的值:
    public static void HandleXML()
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load("C:\\11.xml");
                XmlNode xnRoot = xmldoc.SelectSingleNode("Resp");
                XmlNodeList nodelist = xnRoot.ChildNodes;
                foreach (XmlNode node in nodelist)
                {
                    string Msg=node.SelectSingleNode("Msg").InnerXml;
                    if (Msg !="")
                    {
                        //在此Msg 就是你想要的值
                         Console.WriteLine(Msg);
                    }
                }
            }
      

  2.   

                string path = @"E:\x.xml";
                XmlDocument xml = new XmlDocument();
                xml.Load(path);
                XmlNodeList node= xml.SelectNodes("//name");
                foreach (XmlNode n in node)
                    Console.WriteLine(n.InnerText);
                Console.ReadLine();
      

  3.   


        public XmlDocument xml = new XmlDocument(); string path = @"E:";
                string[] file = Directory.GetFileSystemEntries(path);
                dgvPathWay.Rows.Clear();
                for (int i = 0; i < file.Length; i++)
                {
                    xml.Load(file[i]);
                    XmlElement root = xml.DocumentElement;
                    DataGridView view = new DataGridView();
                    int index = dgvPathWay.Rows.Add(view);
                    dgvPathWay.Rows[index].Cells["name"].Value = root.Name;
                    dgvPathWay.Rows[index].Cells["dept"].Value = root.GetAttribute("");
                }