This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
Writing XML
The following classes may be used to write XML data.
XmlWriter and XmlTextWriter
The abstract XmlWriter class (System.NewXml.XmlWriter) defines methods to output XML documents conforming to the W3C XML 1.0 and Namespaces specifications. These methods merge text specified by the user with standard text appropriate for headers and element types, as well as determining encoding (such as UTF-8), and so on.
The XmlTextWriter class (System.NewXml.XmlTextWriter) extends XmlWriter. The XmlTextWriter class defines methods that write XML data in a forward-only manner to streams, files, and TextWriter objects.
XmlTextWriter has methods and properties to:
- Write a syntactically valid XML declaration and version number, document type, specific start and end tags with namespace decoration, comments, attributes, CDATA, processing instructions, entities and entity references, strings of text, raw markup text (useful when re-routing segments of XML), and so on
- Encode text in base-64, and hexadecimal in appropriate escape characters
- Manage the output, including means to report output state, write multiple documents to one output stream, and flush or close the output
- Report the current namespace prefix, or language or space scope
- Write valid names, qualified names, and name tokens
- Write values or attributes with specific data types such as Boolean; date and time; decimal, single and double precision floating point, and 16-, 32-, or 64-bit integer numbers
- Copy the entire input to the output
- Properties specifying the state of, or whether to, format, encode, indent, or convert data types to tags