TeachingNote

.net xml删除节点

电脑版发表于:2021/4/21 15:32
public ActionResult Remove()
{
    string uri = Server.MapPath("~/xml/book.xml");

    var root = XElement.Load(uri);

    XElement book = root.Element("books").Elements("book").Where(a => a.Attribute("bno").Value == "b001").FirstOrDefault();
    book.Remove();

    root.Save(uri);

    return View();
}


关于TNBLOG
TNBLOG,技术分享。技术交流:群号677373950
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢