Writing XML Documents

To programmatically create and write XML documents, the System.XML namespace provides the XmlTextWriter class.

Reader and Writer Similarities

Before we dig into the guts of writing XML, let's first quickly visit the similarities between the writer class and its reader siblings.

For one, XmlTextWriter is a concrete class that inherits from an abstract parent class called XmlWriter (refer back to Figure 10.3). In a similar manner to XmlReader, the XmlWriter class implements a base set of functionality that can be aggregated through inheritance to implement specialized writers.

Like XmlTextReader, the XmlTextWriter exposes a state property, WriteState, which you can use to query the current state of the writer. XmlTextWriter.WriteState ...

Get Visual Basic® Programmer's Guide to the .NET Framework Class Library 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.