Modifying XML Trees (LINQ to XML)

LINQ to XML is an in-memory store for an XML tree. After you load or parse an XML tree from a source, LINQ to XML lets you modify that tree in place, and then serialize the tree, perhaps saving it to a file or sending it to a remote server.

When you modify a tree in place, you use certain methods, such as Add.

However, there is another approach, which is to use functional construction to generate a new tree with a different shape. Depending on the types of changes that you need to make to your XML tree, and depending on the size of the tree, this approach can be more robust and easier to develop. The first topic in this section compares these two approaches.

In This Section

Topic

Description

In-Memory XML Tree Modification vs. Functional Construction (LINQ to XML)

Compares modifying an XML tree in memory to functional construction.

Adding Elements, Attributes, and Nodes to an XML Tree

Provides information about adding elements, attributes, or nodes to an XML tree.

Modifying Elements, Attributes, and Nodes in an XML Tree

Provides information about modifying existing elements, attributes, or nodes.

Removing Elements, Attributes, and Nodes from an XML Tree

Provides information about removing elements, attributes, or nodes from the XML tree.

Maintaining Name/Value Pairs

Describes how to maintain application information that is best kept as name/value pairs, such as configuration information or global settings.

How to: Change the Namespace for an Entire XML Tree

Shows how to move an XML tree from one namespace into another.

See Also

Concepts

Programming Guide (LINQ to XML)