protected void Button3_Click(object sender, EventArgs e)
    {
        XmlDocument doc = new XmlDocument();
        doc.Load(Server.MapPath("333.xml"));
        string students = TextBox7.Text;
        students = doc.SelectSingleNode("//students[name='" + students + "']").ChildNodes.Item(2).InnerText;
       
    }

解决方案 »

  1.   

    大哥帮个忙咯,如何在C#操作xml查询一条数据?
      

  2.   

    refer : http://blog.csdn.net/chinacsharper/article/category/774613
      

  3.   

    this,sorry? http://blog.csdn.net/chinacsharper/article/details/9246627
      

  4.   

            /// <summary>
            /// 根据索引名称与值读取配置文件的元素节点的目标属性的方法方法
            /// </summary>
            /// <param name="_Path">配置文件路径</param>
            /// <param name="_xmlNodeName">节点名称</param>
            /// <param name="_xmlElementName">元素名称</param>
            /// <param name="_IndexAttributeName">索引属性的名称</param>
            /// <param name="_IndexAttributeValue">索引属性的值</param>
            /// <param name="_TargetAttributeName">目标属性的名称</param>
            /// <returns>返回目标值</returns>
            
            public string GetConfigAttributeValue(string _Path, string _xmlNodeName, string _xmlElementName,
                string _IndexAttributeName, string _IndexAttributeValue, string _TargetAttributeName)
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(_Path);            XmlNode xNode;
                XmlElement xElem;            xNode = xDoc.SelectSingleNode("//" + _xmlNodeName);  // 经测试“//”可以不用            xElem = (XmlElement)xNode.SelectSingleNode("//" + _xmlElementName + "[@" + _IndexAttributeName + "=\"" + _IndexAttributeValue + "\"]");
                if (xElem != null)
                    return xElem.GetAttribute(_TargetAttributeName);           
                else
                    return "";
            }