XElement root = new XElement("Root"); XElement element = new XElement("Child", "Data"); root.Add(element);
XElement root = XElement.Parse(""); var child = root.Element("Child"); Console.WriteLine(child.Value); Data
XElement root = XElement.Parse("This code modifies the value of the Child element to "NewData" and then prints out the modified XML document. The package library for XElement is System.Xml.Linq, which is part of the .NET Framework Class Library."); var child = root.Element("Child"); child.Value = "NewData"; Console.WriteLine(root); Data