c# 读取 XML

XmlDocument xmldoc = new XmlDocument();
string xmlPath = HttpContext.Server.MapPath("~/*****.xml");
xmldoc.Load(xmlPath);
XmlElement root = xmldoc.DocumentElement;
string node = root.SelectSingleNode("/images/image[@id='1']/url").InnerText;
<?xml version="1.0" encoding="utf-8" ?>
<images>
  <image id="0">
    <url>/images/0.png</url>
  </image>
  <image id="1">
    <url>/images/1.png</url>
  </image>
</images>
posted @ 2016-01-22 16:42  chenjingchun  阅读(146)  评论(0编辑  收藏  举报