General-purpose computer programming languages have two components: the language itself and a set of compatible application programming interfaces (APIs) that target specific task or domain categories. As the programming tasks or domain that a particular API targets become more common, users request that the API be integrated into the language. The organizations that control the language's development usually comply with these requests because integration with the language makes use of the former API more convenient. LINQ to XML carries API integration to a new extreme by leapfrogging .NET's API-based
System.Xml classes with an implementation that dramatically simplifies querying and generating XML Infosets and is embedded in the CLR. LINQ to XML provides XML Infoset navigation and query capabilities that equal or surpasses XQuery 1.0 and rival XPath 2.0. For document transformation, LINQ to XML can replace XQuery 1.0 or XSLT 1.0+ in the majority of common use cases.
The LINQ to XML topic of Chapter 1 introduced you to value-based queries against single and multiply-joined documents. This chapter extends those basic examples to queries for navigating real-world XML documents and composable code for generating hierarchical Infosets from Visual Basic 9.0's literal XML data type and the C# alternative, functional construction.
This chapter assumes familiarity with XML entities (such as elements, attributes, names, namespaces, declarations ...