System.Xml.XmlDocument loadDoc = new System.Xml.XmlDocument();
        loadDoc.Load(Application.StartupPath + "\\用户信息表.xml");        foreach (System.Xml.XmlNode nameNode in loadDoc.SelectNodes("//UserMessage"))
        {
            listView1.Items.Add(nameNode.Attributes["Access文件"].InnerText); ;
        }

解决方案 »

  1.   

    我在提供一个轻量级的操作xml的类XDocumentXDocument xDoc = XDocument.Load("文件路径");
    foreach (XElement item in xDoc.Root.Descendants(“UserMessage”))
                {
                    listView1.Items.Add(item.Attribute("Access文件").Value);
                }
      

  2.   

    读取XML文档的节点
    //引入命名空间
    using System.Xml;
    //加载读取节点绑定自定义方法显示页面
      protected void Page_Load(object sender, EventArgs e)
      
                XmlDocument doc = new XmlDocument();//创建并实例化一个XmlDocument对象
                doc.Load(Server.MapPath("LeaveWord.xml"));//将LeaveWord.xml文件内容装载到内存
                bindXml();帮定自定义方法控件显示内容
            }
    //自定义方法
    public void bindXml()
        {
            
            XmlDocument mydoc = this.XmlDataSourceLW.GetXmlDocument();
        }
      

  3.   

    用linq to xml去做吗  去网上看下 就会了