XElement element = XElement.Parse(""); // Accessing the 'age' attribute value string age = (string) element.Attribute("age");
XElement element = XElement.Parse("Hello, world! "); // Updating the element value element.Value = "Goodbye, world!";
XElement newElement = new XElement("book", new XElement("title", "The Great Gatsby"), new XElement("author", "F. Scott Fitzgerald"), new XElement("year", 1925) ); XDocument document = new XDocument(newElement);In short, XElement Elements allows developers to easily manipulate XML elements in C#. It is part of the System.Xml.Linq package.