Chapter 10. Query and transform XML with LINQ to XML

 

This chapter covers:

  • LINQ to XML query axis methods
  • Querying XML documents using LINQ to XML
  • Transforming XML

Over the last several years, many websites have begun to offer public XML web services that allow developers to access the data inside their site. Amazon.com provides a set of e-commerce web services that allow you to search their product catalog, Flickr lets you grab photographs that people have identified as interesting, and del.icio.us exposes XML feeds that allow you to keep abreast of websites that users have added to their bookmarks. By providing this data to clients as XML, Amazon, Flickr, and del.icio.us have enabled third-party developers to tie into their platforms to create compelling applications.

In order to do interesting things with the data contained in the XML, developers need a toolset that allows them to query the XML for the individual pieces of data that are of interest. With Amazon, they need to be able to read product details out of the XML feed, with Flickr it’s the photograph details, and with del.icio.us it’s the URL of the site that’s been bookmarked.

10.1. LINQ to XML axis methods

10.2. Standard query operators

10.3. Querying LINQ to XML objects with XPath

10.4. Transforming XML

10.5. Summary