Writing XML Attributes

In this section we examine how to write attributes on elements. We also look at declaring namespace prefixes and creating the xml:space and xml:lang attributes.

Just like elements, attributes can be constructed piece by piece or written all at once. Writing attributes piece by piece is similar to writing an element piece by piece. The WriteStartAttribute and WriteEndAttribute methods provide this functionality.

WriteStartAttribute writes the start of an attribute, “name=”, or a start attribute with an optional user-defined namespace prefix, “prefix:name=”. WriteStartAttribute needs to be followed by a call to some method that will write the content of the attribute. The WriteEndAttribute method should be called after writing ...

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.