Writing Well-Formed XML Text

The XmlTextWriter class takes a number of precautions to ensure that the final XML code is perfectly compliant with the XML 1.0 standard of well-formedness. In particular, the class verifies that any special character found in the passed text is automatically escaped and that no elements are written in the wrong order (such as attributes outside nodes, or CDATA sections within attributes). Finally, the Close method performs a full check of well-formedness immediately prior to return. If the verification is successful, the method ends gracefully; otherwise, an exception is thrown.

Other controls that the XmlTextWriter class performs on the generated XML output ensure that each document starts with the standard XML ...

Get Applied XML Programming for Microsoft® .NET 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.