zoukankan      html  css  js  c++  java
  • xml delete

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load("bookstore.xml");
                XmlNodeList xnl = xmlDoc.SelectSingleNode("bookstore").ChildNodes;

                foreach (XmlNode xn in xnl)
                {
                    XmlElement xe = (XmlElement)xn;
                    if (xe.GetAttribute("genre") == "fantasy")
                    {
                        xe.RemoveAttribute("genre");//删除genre属性  
                    }
                    else if (xe.GetAttribute("genre") == "update红")
                    {
                        xe.RemoveAll();//删除该节点的全部内容  
                    }
                }
                xmlDoc.Save("bookstore.xml");  

  • 相关阅读:
    Java经典习题7
    Java经典习题6
    java经典习题5
    前后端分离开发——模拟数据mock.js
    微信网页第三方登录原理
    TP5常量
    TP5
    健忘的正则
    JS正则
    apache配置修改
  • 原文地址:https://www.cnblogs.com/greencolor/p/1637765.html
Copyright © 2011-2022 走看看