XElement.Name gets or sets the name of this element.
using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass{
public static void Main(){
XElement el1 = new XElement("Root", "content");
Console.WriteLine(el1.Name);
XNamespace ns = "http://www.domain.com";
XElement el2 = new XElement(ns + "Root", "content");
Console.WriteLine(el2.Name);
Console.WriteLine(el2.Name.Namespace);
Console.WriteLine(el2.Name.LocalName);
el2.Name = ns + "NewName";
Console.WriteLine(el2.Name);
}
}
Related examples in the same category