7.1. Create an XML Document

Problem

You need to create some XML data and save it to a file.

Solution

Use XML literals to create a System.Xml.Linq.XElement object, and then use the Save method to save the XML tree to a file.

How It Works

The .NET Framework provides several different ways to process XML documents. The one you use depends on the programming task you are attempting to accomplish. The .NET Framework 3.5 includes classes that provide the functionality to manipulate and query XML files. Although all previous versions of .NET supported similar functionality, the new LINQ to XML classes, the most common of which can be found in Table 7-1, have greatly enhanced its support of the W3C Document Object Model (DOM). The DOM dictates how XML ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach 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.