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






XElement.Remove

  
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() {
        XElement firstParticipant;
        XDocument xDocument = new XDocument(
          new XElement("Books", firstParticipant =
            new XElement("Book",
              new XAttribute("type", "Author"),
              new XElement("FirstName", "A"),
              new XElement("LastName", "B")),
            new XElement("Book",
              new XAttribute("type", "Author"),
              new XElement("FirstName", "C"),
              new XElement("LastName", "D"))));
        Console.WriteLine(xDocument);
        firstParticipant.Remove();
        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.RemoveAll
22.XElement.Save(String fileName)
23.XElement.SetAttributeValue
24.XElement.SetElementValue