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