当前位置: 代码迷 >> ASP.NET >> 求解xml资料
  详细解决方案

求解xml资料

热度:10119   发布时间:2013-02-25 00:00:00.0
求解xml文件
一个XML标签<name text="test2">hello</name>中,asp.net中如何取得name中text的值,帮忙解决一下,谢谢


------解决方案--------------------------------------------------------
XmlNode.Attributes[属性名]
------解决方案--------------------------------------------------------
C# code
        XmlDocument xmldoc = new XmlDocument();        xmldoc.Load(Server.MapPath("xmltest.xml"));        XmlNode xn = xmldoc.SelectSingleNode("//data/name");        Response.Write(xn.Attributes["text"].Value);
------解决方案--------------------------------------------------------
C# code
XElement xEl=XElement.Load(@"C:\Documents and Settings\Administrator\桌面\Test.txt");                string value = xEl.Value;//hello
  相关解决方案