Removing XmlAttributes from their XmlElements

The API for removing attributes is much richer than that for removing other nodes. This is due to the ability to remove nodes through methods on the XmlAttributeCollection class as well as methods on the XmlElement class.

The XmlAttributeCollection class provides three methods for removing an XmlAttribute: Remove, RemoveAt, and RemoveAll. The Remove method removes a single specified attribute from the attribute collection. The RemoveAt method removes a single attribute corresponding to the specified index from the collection. The RemoveAll method removes all of the attributes in the collection. Listing 11.28 demonstrates how to use each method.

Listing 11.28.
 C# XmlDocument doc = new XmlDocument(); ...

Get Microsoft® .NET Compact Framework Kick Start 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.