.net xml更新节点
电脑版发表于:2021/4/21 15:33
public ActionResult Update() { string uri = Server.MapPath("~/xml/boos2.xml"); var root = XElement.Load(uri); XElement book = root.Element("books").Elements("book").Where(a => a.Attribute("bno").Value == "b001").FirstOrDefault(); book.ReplaceNodes(new XElement("sister", "嘿嘿"), new XElement("height", "180kg")); root.Save(uri); return View(); }