标签:round microsoft span ice ros XML load name enc
<?xml version="1.0" encoding="UTF-8"?>
<Freight>
<freight Area="河南" ExpreName="圆通">
<FreYkg>1000</FreYkg>
<FreYkgPrice>800</FreYkgPrice>
<FreAkg>2000</FreAkg>
<FreAkgPrice>200</FreAkgPrice>
</freight>
<freight Area="河北" ExpreName="圆通">
<FreYkg>1000</FreYkg>
<FreYkgPrice>800</FreYkgPrice>
<FreAkg>2000</FreAkg>
<FreAkgPrice>200</FreAkgPrice>
</freight>
</Freight>
想要获取的内容是:Area="河北" 下某节点值,应该怎么读取
XmlDocument doc = new XmlDocument();
string path = Server.MapPath("../Xml/EMS.xml");
doc.Load(path);
XmlNode node = doc.SelectSingleNode("Freight/freight[@Area=‘河北‘]|Freight/freight[@ExpreName=‘圆通‘]");/*查询的条件Area=‘河北‘ 或者 ExpreName=‘圆通‘*/
if(node!=null)
{
string basePrice = node.SelectSingleNode("FreYkg").InnerText;
string price = node.SelectSingleNode("FreYkgPrice").InnerText;
}
标签:round microsoft span ice ros XML load name enc
原文地址:https://www.cnblogs.com/xiaxiaomo/p/9044730.html