XmlElement.RemoveAll Method ()


Removes all specified attributes and children of the current node. Default attributes are not removed.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public override void RemoveAll()

The following example removes all attributes and child nodes from the root element.

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

public class Sample
  public static void Main()

    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<book xmlns:bk='urn:samples' bk:ISBN='1-861001-57-5'>" +
                "<title>Pride And Prejudice</title>" +

    // Remove all attributes and child nodes from the book element.
    XmlElement root = doc.DocumentElement;

    Console.WriteLine("Display the modified XML...");

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top