Remove the attributes from XElement in CSharp

Description

The following code shows how to remove the attributes from XElement.

Example


using System;/*from  w  w  w. java  2s.c  o m*/
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;


public class MainClass{
   public static void Main(){
        XElement root = new XElement("Root",
            new XAttribute("Att1", 1),
            new XAttribute("Att2", 2),
            new XAttribute("Att3", 3),
            new XElement("Child1", 1),
            new XElement("Child2", 2),
            new XElement("Child3", 3)
        );
        root.RemoveAttributes();
        Console.WriteLine(root);
    }
}




















Home »
  C# Tutorial »
    XML »




Load Parse
Document
Element
Attribute
Namespace
Query
Save
Schema
Style