Writing Raw XML Markup

The XmlTextWriter provides a rich API for writing well-formed markup to an XML stream. There may be times when you need to strip away this rich API and write raw text to the XML stream without the XmlTexWriter's attempting to encode the text. This could be helpful if your markup input is created by an external source and you just want to paste that markup into the XML stream.

The WriteRaw method provides this functionality. This method will not check the string for well-formedness. No encoding will be done, and no characters will be replaced with their respective character entities. The text is written “as is” to the XML stream. You can forget about formatting, too. Listing 10.32 demonstrates how to use WriteRaw to write ...

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.