O'Reilly logo

Pro LINQ: Language Integrated Query in C# 2008 by Joseph C. Rattz Jr.

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

XML Creation

As I have already discussed, functional construction provided by the LINQ to XML API makes creating an XML tree a breeze compared to the W3C DOM API. We will now take a look at creating each of the major XML classes in the LINQ to XML API.

Because the new API is centered on elements, and that is what you will be creating the majority of the time, I cover creating elements with the XElement class first. I then cover the rest of the XML classes in alphabetical order.

Creating Elements with XElement

First, you should keep in mind that with the new API, the XElement class is the one you will use most. That said, let's take a look at instantiating an XElement object. XElement has several constructors, but I am going to examine two of ...

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