Inserting XmlAttributes into an XmlDocument

XmlAttributes can be inserted into a document by using the SetAttribute method described earlier in this chapter. Alternatively, you can add them using the insertion methods on the XmlAttributeCollection class. The insertion methods, similar to the XmlNode insertion methods, are Append, Prepend, InsertBefore, and InsertAfter.

Append and Prepend add an XmlAttribute to the end of the attribute list and to the beginning of the attribute list, respectively. The methods return the XmlAttribute that was inserted. If there exists an attribute in the collection with the same name, then the original attribute is removed from the collection, and the new attribute is added. Listing 11.23 illustrates how to use ...

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.