linq 读取xml

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;
}

  

 

posted @ 2015-01-14 12:31  需要GIS小工具找我  阅读(368)  评论(0编辑  收藏  举报