O'Reilly logo

Professional ADO.NET 3.5 with LINQ and the Entity Framework by Roger Jennings

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Manipulating Documents with LINQ to XML

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required