日期:2014-05-17 浏览次数:20516 次
<?xml version='1.0' encoding='utf-8'?>
<date>
<category name='E1'>
<property name='serviceType' value='服务1'/>
<property name='calcMethod' value='垫付额度'/>
<property name='amount' value='100'/>
</category>
<category name='E1'>
<property name='serviceType' value='服务2'/>
<property name='calcMethod' value='次数'/>
<property name='amount' value='200'/>
</category>
</date>
XElement root = XElement.Load("a.xml");
var items = root.XPathSelectElements("category/@name='E1'");
foreach(var item in items)
{
// do something
}
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("~/test.xml"));
XmlNodeList nodes = xmlDoc.SelectNodes("/date/category[@name='E1']");
foreach (XmlNode node in nodes)
{
foreach (XmlNode attr in node.SelectNodes("property/@value"))
Response.Write(attr.Value + "<br/>");
Response.Write("<br/>");
}