Modifying Elements, Attributes, and Nodes in an XML Tree
The following table summarizes the methods and properties that you can use to modify an element, its child elements, or its attributes.
The following methods modify an XElement.
Method |
Description |
---|---|
Replaces an element with parsed XML. |
|
Removes all content (child nodes and attributes) of an element. |
|
Removes the attributes of an element. |
|
Replaces all content (child nodes and attributes) of an element. |
|
Replaces the attributes of an element. |
|
Sets the value of an attribute. Creates the attribute if it doesn't exist. If the value is set to null, removes the attribute. |
|
Sets the value of a child element. Creates the element if it doesn't exist. If the value is set to null, removes the element. |
|
Replaces the content (child nodes) of an element with the specified text. |
|
Sets the value of an element. |
The following methods modify an XAttribute.
Method |
Description |
---|---|
Sets the value of an attribute. |
|
Sets the value of an attribute. |
The following methods modify an XNode (including an XElement or XDocument).
Method |
Description |
---|---|
Replaces a node with new content. |
The following methods modify an XContainer (an XElement or XDocument).
Method |
Description |
---|---|
Replaces the children nodes with new content. |