7.5. Remove or Replace Elements or Attributes
Problem
You need to modify an XML document by completely removing or replacing certain attributes or elements.
Solution
Use one of the available replace or remove methods of the XElement class.
How It Works
The XElement class provides the following methods for replacing or removing elements or attributes in an existing XML tree:
RemoveAll removes all elements (nodes and attributes) from the element represented by the current XElement instance.
RemoveAttributes removes all the attributes from the element represented by the current XElement instance.
ReplaceAll removes all the elements (nodes and attributes) from the element represented by the current XElement instance and replaces them with the element ...
Get Visual Basic 2008 Recipes: A Problem-Solution Approach 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.