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 Modification

Modifying XML data is easier than ever with the LINQ to XML API. With just a handful of methods, you can perform all the modifications you could want. Whether it is adding, changing, or deleting nodes or elements, there is a method to get the job done.

As has been stated time and time again, with the LINQ to XML API, you will be working with XElement objects most of the time. Because of this, the majority of these examples are with elements. The LINQ to XML API classes inheriting from XNode are covered first, followed by a section on attributes.

Adding Nodes

In this section on adding nodes to an XML tree, I start with a base example of the code in Listing 7-62.

Example. A Base Example with a Single Book Participant
// A document ...

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