You can generate, query, and manipulate XML documents using LINQ (Language Integrated Query) thanks to a technology called LINQ to XML. It offers a set of classes that make it simple to interact with XML using LINQ and are built on top of the common XML classes provided by the.NET framework (such as XElement and XDocument).   The XElement and XDocument classes can be used to build the structure of an XML document when using LINQ to XML. As an illustration, the code that follows generates an XML document having a single element called "root" and two child elements named "child1" and "child2"  XElement root = new XElement("root",
new XElement("child1", "value1"),
new XElement("child2", "value2")
); By parsing an existing XML string or file using the XDocument.Parse() or XDocument.Load() method, you can also construct an XML document.   The XElement and XDocument objects, which stand in for the document's elements and nodes, respectively, can be used to query an XML document using LINQ to XML. These operators include Where, Select, and OrderBy. For instance, the code that follows looks for all "child"-named elements in an XML document.  XElement root = ...; // assume this is the root element of the XML document
IEnumerable childElements =
from el in root.Elements("child")
select el;  Additionally, you may use XElement and XDocument ways that are similar to XPath, such as Descendants, Elements, Attributes, and Value, to query an XML document. You can also combine these methods with common LINQ query terms like where, select, orderby, and so forth.   The XElement and XDocument classes' methods and properties can be used to change the data and update the XML document as necessary once you have queried the document and obtained a collection of elements or nodes.