简单的都用dataset 不过看你的结构有点复杂不知道 dataset 能hold住不,估计你还是要看文档啊
提供个用dataset的简单使用
dataset ds = new dataset();
ds.readxml("这是xml的路径");然后xml中的数据就会在ds.tables里了 你自己研究下吧

解决方案 »

  1.   


    CN_UTILITY.ComputerSystem csys = new ComputerSystem();
                    string sAllUserAppDataPath = csys.GetFolderPath();//获取系统AllUser下Application Data文件夹目录                string sWLApplication = sAllUserAppDataPath + "\\JiuJiuTong";
                    string sWlTraFile = sWLApplication + "\\***.tra";                if (!Directory.Exists(sWLApplication))//判断目录是否存在
                    {
                        Directory.CreateDirectory(sWLApplication);
                    }
                    XmlDocument doc = new XmlDocument();
                    if (!File.Exists(sWlTraFile))//文件不存在
                    {
                        string sCpuId = csys.GetCpuId();//获取电脑CPU编号                     XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
                        doc.AppendChild(xmlnode);//加入XML的声明段落
                        XmlElement Root = doc.CreateElement("Root");
                        XmlElement E_CPU = doc.CreateElement("CPU");
                        XmlElement E_DATE = doc.CreateElement("DATE");
                        E_CPU.InnerText = sCpuId;
                        E_DATE.InnerText = DateTime.Now.ToString();
                        Root.AppendChild(E_CPU);
                        Root.AppendChild(E_DATE);
                        doc.AppendChild(Root);
                        doc.Save(sWlTraFile);                    return true;
                    }
                    else
                    {
                        doc.Load(sWlTraFile);//打开指定文件
                        XmlNode cpu = doc.SelectSingleNode("Root//CPU");                    XmlNode date = doc.SelectSingleNode("Root//DATE");                    
    if (cpu != null && date != null)
                        {
                            if (DateTime.Compare(DateTime.Now, Convert.ToDateTime(date.InnerText).AddHours(24)) < 0)
                            {
                                return true;
                            }
                        }
                        return false;
                    }
    看这段解析XML代码,希望对于你有所帮助
      

  2.   


    <?xml version="1.0"?>
    <Root>
      <CPU>BFEBFBFF0001067A</CPU>
      <DATE>2012-1-8 17:24:33</DATE>
    </Root>
    这是XML文件内容,很简单
      

  3.   

     XmlDocument treedoc = new XmlDocument();
                treedoc.LoadXml(xml内容);
      

  4.   


    XmlDocument xmlDoc= new XmlDocument();
    xmlDoc.LoadXml("xml文件路径");
    XmlNodeList itemList = xmlDoc.SelectNodes("xml//Root//Person ");
                    foreach (XmlNode node in itemList)
                    {
                        string idCard = node.Attributes["IDCard"].Value;
                        //....
                        //....
                        //....
                    }
    再不会,哥也没招了
      

  5.   


    我开始就是用的dataset,但是里面解析出来的内容不全。
      

  6.   


    #region 显示XML数据
       private void ReadXML()
       {
        string url = Server.MapPath("user.xml");//获得当前文件夹下的XML文件
        StreamReader sRead = new StreamReader(url,System.Text.Encoding.GetEncoding("GB2312"));//以一种特定的编码从字节流读取字符,必须要转化成GB2312读取才不能出乱码
        XmlDataDocument datadoc = new XmlDataDocument();//操作XML文档
        datadoc.DataSet.ReadXml(sRead);//将读取的字节流存到DataSet里面去
        this.DataGrid1.DataSource = datadoc.DataSet.Tables[0].DefaultView;
        DataGrid1.DataKeyField="username";//以username建立索引
        this.DataGrid1.DataBind();
        datadoc = null;//清空对XML数据的操作
        sRead.Close();//关闭字节流的读取
       }
       #endregion
    public class XmlControl 

    protected string strXmlFile; 
    protected XmlDocument objXmlDoc = new XmlDocument();public XmlControl(string XmlFile) 

    // 
    // TODO: 在这里加入建构函式的程序代码 
    // 
    try 

    objXmlDoc.Load(XmlFile); 

    catch (System.Exception ex) 

    throw ex; 

    strXmlFile = XmlFile; 
    }public DataView GetData(string XmlPathNode) 

    //查找数据。返回一个DataView 
    DataSet ds = new DataSet(); 
    StringReader read = new StringReader(objXmlDoc.SelectSingleNode(XmlPathNode).OuterXml); 
    ds.ReadXml(read); 
    return ds.Tables[0].DefaultView; 
    }public void Replace(string XmlPathNode,string Content) 

    //更新节点内容。 
    objXmlDoc.SelectSingleNode(XmlPathNode).InnerText = Content; 
    }public void Delete(string Node) 

    //删除一个节点。 
    string mainNode = Node.Substring(0,Node.LastIndexOf("/")); 
    objXmlDoc.SelectSingleNode(mainNode).RemoveChild(objXmlDoc.SelectSingleNode(Node)); 
    }public void InsertNode(string MainNode,string ChildNode,string Element,string Content) 

    //插入一节点和此节点的一子节点。 
    XmlNode objRootNode = objXmlDoc.SelectSingleNode(MainNode); 
    XmlElement objChildNode = objXmlDoc.CreateElement(ChildNode); 
    objRootNode.AppendChild(objChildNode); 
    XmlElement objElement = objXmlDoc.CreateElement(Element); 
    objElement.InnerText = Content; 
    objChildNode.AppendChild(objElement); 
    }public void InsertElement(string MainNode,string Element,string Attrib,string AttribContent,string Content) 

    //插入一个节点,带一属性。 
    XmlNode objNode = objXmlDoc.SelectSingleNode(MainNode); 
    XmlElement objElement = objXmlDoc.CreateElement(Element); 
    objElement.SetAttribute(Attrib,AttribContent); 
    objElement.InnerText = Content; 
    objNode.AppendChild(objElement); 
    }public void InsertElement(string MainNode,string Element,string Content) 

    //插入一个节点,不带属性。 
    XmlNode objNode = objXmlDoc.SelectSingleNode(MainNode); 
    XmlElement objElement = objXmlDoc.CreateElement(Element); 
    objElement.InnerText = Content; 
    objNode.AppendChild(objElement); 
    }public void Save() 

    //保存文檔。 
    try 

    objXmlDoc.Save(strXmlFile); 

    catch (System.Exception ex) 

    throw ex; 

    objXmlDoc = null; 

    }=========================================================实例应用:string strXmlFile = Server.MapPath("TestXml.xml"); 
    XmlControl xmlTool = new XmlControl(strXmlFile);// 数据显视 
    // dgList.DataSource = xmlTool.GetData("Book/Authors[ISBN=\"0002\"]"); 
    // dgList.DataBind();// 更新元素内容 
    // xmlTool.Replace("Book/Authors[ISBN=\"0002\"]/Content","ppppppp"); 
    // xmlTool.Save();// 添加一个新节点 
    // xmlTool.InsertNode("Book","Author","ISBN","0004"); 
    // xmlTool.InsertElement("Book/Author[ISBN=\"0004\"]","Content","aaaaaaaaa"); 
    // xmlTool.InsertElement("Book/Author[ISBN=\"0004\"]","Title","Sex","man","iiiiiiii"); 
    // xmlTool.Save();// 删除一个指定节点的所有内容和属性 
    // xmlTool.Delete("Book/Author[ISBN=\"0004\"]"); 
    // xmlTool.Save();// 删除一个指定节点的子节点 
    // xmlTool.Delete("Book/Authors[ISBN=\"0003\"]"); 
    // xmlTool.Save();
      

  7.   

    C# Linq使用XDocument读取Xml文件并形成结构树数据(json)  
    http://www.suchso.com/projecteactual/Csharp-Linq-XDocument-Xml-File-Tree-Data.html