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.
In this section on adding nodes to an XML tree, I start with a base example of the code in Listing 7-62.
// A document ...