·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> 网站建设开发 >> ASP.NET网站开发 >> linq读取xml

linq读取xml

作者:佚名      ASP.NET网站开发编辑:admin      更新时间:2022-07-23

xml 文件如下:

<?xml version="1.0" encoding="utf-8" ?>
<nodes>
<node>
<项目类型>农用地转用</项目类型>
</node>
</nodes>

 

相关的代码如下:

string xmlPath = application.StartupPath + @"\config.xml";
XDocument xd = XDocument.Load(xmlPath);
string xmlx = "";
foreach (XElement item in xd.Root.Descendants("node"))//得到每一个node节点,得到这个节点再取他的xmlx的这个节点
{
xmlx=item.Element("项目类型").Value;
}