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");  

  • 相关阅读:
    用python将博客园的文章爬取到本地
    2016.7.9
    2016.7.8
    2016.7.7
    2016.7.5
    2016.7.4
    2016.7.3
    2016.7.2
    2016.6.28
    2016.6.27
  • 原文地址:https://www.cnblogs.com/greencolor/p/1637765.html
Copyright © 2011-2022 走看看