Beginning xml with C# 2008

pp 421-456

Working with LINQ to XML

* Final gross prices may vary according to local VAT.

Get Access


Traditionally, software systems used different methods of accessing data from different data stores. For example, in order to access data from relational databases, flat files, and XML files, developers needed to learn and master different object models. These object models were often totally different from each other in terms of usage syntax and underlying philosophy. Beginning with the .NET Framework 3.5, Microsoft introduced Language Integrated Query (LINQ) technology that simplifies the hassle involved while consuming different sources of data. Though LINQ is a relatively new technology, it is already getting good attention from .NET developers. LINQ comes in three main flavors: LINQ to objects, LINQ to ADO.NET, and LINQ to XML. This chapter will cover LINQ to XML features along with a brief primer on LINQ in general. Remember, however, that any detailed coverage of LINQ technology is beyond the scope of this book. This chapter restricts itself to the following topics:
  • Brief introduction to LINQ expressions

  • Capabilities of LINQ to XML

  • When to use LINQ to XML

  • Loading and saving XML documents using LINQ to XML

  • Manipulating XML documents using LINQ to XML

  • Validating XML documents using LINQ to XML

  • Transforming XML documents using LINQ to XML