XElement.RemoveAll : XElement « System.Xml.Linq « C# / C Sharp by API






XElement.RemoveAll

  

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Linq;
public class MainClass {
    public static void Main() {
        XDocument xDocument = new XDocument(
          new XElement("Books",
            new XElement("Book",
              new XAttribute("type", "Author"),
              new XElement("FirstName", "J"),
              new XElement("LastName", "R")),
            new XElement("Book",
              new XAttribute("type", "Author"),
              new XElement("FirstName", "E"),
              new XElement("LastName", "B"))));
        Console.WriteLine(xDocument);
        xDocument.Element("Books").RemoveAll();
        Console.WriteLine(xDocument);
    }
}

   
    
  








Related examples in the same category

1.new XElement
2.XElement.AddFirst
3.XElement.Ancestors()
4.XElement.AncestorsAndSelf()
5.XElement.AncestorsAndSelf(String tagName)
6.XElement.Attribute
7.XElement.Changed
8.XElement.Changing
9.XElement.Descendants
10.XElement.Descendants("firstname").First()
11.XElement.Elements
12.XElement.First
13.XElement.FirstAttribute
14.XElement.GetSchemaInfo()
15.XElement.HasAttributes
16.XElement.HasElements
17.XElement.Load(String fileName)
18.XElement.Nodes()
19.XElement.Parent
20.XElement.Parse(String xml value)
21.XElement.Remove
22.XElement.Save(String fileName)
23.XElement.SetAttributeValue
24.XElement.SetElementValue