adsense

Thursday, November 16, 2017

Removing XML Nodes from a XML Document

Following code can be used to remove a XmlNode with all the children nodes

      XmlDocument doc = new XmlDocument();
        doc .Load(MapPath("~/FileName.xml"));
        XmlNodeList selectedNodes = doc .SelectNodes("//SubNode");
      
       foreach (XmlNode node in selectedNodes )
        {
            node.ParentNode.RemoveChild(node);
        }

Regards,
Samitha

No comments:

Post a Comment