The previous two chapters introduced LINQ (Language-Integrated Query) and showed how LINQ works with objects and databases. This chapter introduces LINQ to XML, which is the version of LINQ that enables you to use LINQ to query and manipulate XML (Extensible Markup Language).
You learned about XML in Chapter 25, so that is not covered again here. You should be familiar with XML documents, elements, attributes, and so on before proceeding further in this chapter, so if you haven't read the introduction to XML at the beginning of Chapter 25, do so now.
LINQ to XML is not intended to replace the standard XML APIs such as XML DOM (Document Object Model), XPath, XQuery, XSLT, and so on. If you are familiar with these APIs or currently need to use them or learn them, you should continue to do so.
LINQ to XML supplements these standard XML classes and makes working with XML easier. LINQ to XML gives you extra options for creating and querying XML data, resulting in simpler code and quicker development for many common situations, especially if you are already using LINQ to Objects or LINQ to SQL in other parts of your programs.
In learning LINQ to XML, in particular you will look at the following:
How to easily create XML documents with LINQ to XML functional constructor methods.
How to format, load, and save XML documents with LINQ to XML.
How use LINQ to XML to work with incomplete XML documents (fragments).
How to generate an XML document from a LINQ to SQL or LINQ to ...