O'Reilly logo

Beginning Microsoft® Visual C#® 2008 by Eric White, Morgan Skinner, Jon D. Reid, Jacob Hammer Pedersen, Christian Nagel, Karli Watson

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 29. LINQ to XML

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

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