日期:2014-05-17 浏览次数:20427 次
<tops>
<list>
<memberSerials>A0000008</memberSerials>
<names>heihei</names>
<marks>98</marks>
<times>00:01:20</times>
</list>
<list>
<memberSerials>J00002</memberSerials>
<names>jeson</names>
<marks>150</marks>
<times>00:01:25</times>
</list>
<list>
<memberSerials>J0001</memberSerials>
<names>jicemo</names>
<marks>50</marks>
<times>00:01:05</times>
</list>
<list>
<memberSerials>J00002</memberSerials>
<names>jeso</names>
<marks>98</marks>
<times>00:01:20</times>
</list>
<list>
<memberSerials>J00002</memberSerials>
<names>jes</names>
<marks>150</marks>
<times>00:01:25</times>
</list>
</tops>
var memberSerials = from c in XElement.Load(Context.Server.MapPath("~/Xml.xml")).Descendants("memberSerials").Where(x=>x.Value=="A0000008")
select c;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("~/test1.xml"));
XmlElement elem = xmlDoc.SelectSingleNode("//list[memberSerials='A0000008']/marks") as XmlElement;
Response.Write(elem.InnerText + "<br/>");
elem.InnerText = "188";
Response.Write("修改后的值:" + elem.InnerText);
xmlDoc.Save(Server.MapPath("~/test1.xml")); //保存回xml文件