Removes all the child nodes and/or attributes of the current node. : XML Node « XML « C# / C Sharp





Removes all the child nodes and/or attributes of the current node.

 

using System;
using System.IO;
using System.Xml;

public class Sample {

  public static void Main() {

    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<book genre='novel' ISBN='1-111111-57-5'>" +
                "<title>C#</title>" +
                "</book>");

    XmlNode root = doc.DocumentElement;
    root.RemoveAll();
    doc.Save(Console.Out);
  }
}

   
  










Related examples in the same category

1.Create an element type XmlNode like text value
2.Get the Xml Text node value
3.Set the value to the Element
4.Alphabetical sorting of the XmlNodes
5.Convert an XmlNode to an object
6.Adds the specified node to the end of the list of child nodes, of this node.
7.Gets an XmlAttributeCollection containing the attributes of this node.
8.Gets all the child nodes of the node.
9.Creates a duplicate of this node.
10.Creates an XPathNavigator for navigating this object.
11.Gets the first child of the node.
12.For each style iteration over the nodes in the XmlNode.
13.Looks up the closest xmlns declaration for the given namespace URI
14.Gets or sets the concatenated values of the node and all its child nodes.Gets or sets the concatenated values of the node and all its child nodes.
15.Inserts the specified node immediately after the specified reference node.
16.Inserts the specified node immediately before the specified reference node.
17.Gets the first child element with the specified Name.
18.Gets the last child of the node.
19.Gets the node immediately following this node.
20.Gets the markup representing this node and all its child nodes.
21.Adds node to the beginning of the list of child nodes
22.Gets the node immediately preceding this node.
23.Removes specified child node.
24.Replaces the child node oldChild with newChild node.
25.Selects a list of nodes matching the XPath expression.
26.Select and display the value of all the ISBN attributes
27.Selects the first XmlNode that matches the XPath expression.
28.When overridden in a derived class, saves all the child nodes of the node to the specified XmlWriter.
29.Save the current node to the specified XmlWriter.