3.3. Creating and Modifying XML Documents

LINQ to XML doesn't only provide for queries; it also provides for creating and modifying XML documents. Thanks to a feature called functional construction, you can create XML documents in an easier way than with the W3C DOM library.

We'll use functional construction to create an XML document from scratch, and then use other LINQ to XML features to manage it.

Finally, we'll look at a couple of examples that integrate LINQ to XML with LINQ to SQL to generate XML output from a database query.

3.3.1. Creating an XML Document from Scratch

If you are accustomed to using the W3C DOM library or the .NET Framework implementation of it, you'll find LINQ to XML very easy and more intuitive to use. The very simple ...

Get LINQ for Visual C# 2008 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.