LINQ to XML Introduction

So you want to be an XML hero? Are you willing to suffer the slings and arrows? Listing 6-1 shows some code that merely creates a trivial XML hierarchy using Microsoft's original XML Document Object Model (DOM) API, which is based on the W3C DOM XML API, demonstrating just how painful that model can be.

Example. A Simple XML Example
using System.Xml; // I'll declare some variables I will reuse. XmlElement xmlBookParticipant; XmlAttribute xmlParticipantType; XmlElement xmlFirstName; XmlElement xmlLastName; // First, I must build an XML document. XmlDocument xmlDoc = new XmlDocument(); // I'll create the root element and add it to the document. XmlElement xmlBookParticipants = xmlDoc.CreateElement("BookParticipants"); ...

Get Pro LINQ: Language Integrated Query in C# 2008 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.