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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access