XmlWriter and Its Subclasses
XmlWriter
is an abstract base class
that defines the interface for creating XML output programmatically.
It contains methods such as WriteStartElement( )
and WriteEndElement( )
to write data.
XmlWriter
maintains the state of the XML document
as it writes, so it knows which start element or attribute to close
when you call WriteEndElement( )
or
WriteEndAttribute( )
.
XmlTextWriter
is the subclass of
XmlWriter
, which provides support for output of
XML to any Stream
, filename, or
TextWriter
. In addition to all the required
features of an XmlWriter
,
XmlTextWriter
allows you to set the formatting of
the output, using the Formatting
,
Indentation
, IndentChar
,
Namespaces
, and QuoteChar
properties.
The XmlTextWriter
formatting properties are
described in Table 3-6.
Property |
Type |
Description |
Formatting |
System.Xml.Formatting |
Specify |
Indentation |
int |
If |
IndentChar |
char |
If |
Get .NET & XML 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.