Writing Element and Attribute Content

Writing elements and attributes piece by piece requires you to write the content separately from the start and end tags. Up to this point, this chapter has glossed over which methods are available for writing this content. This section will investigate these methods in more detail.

The XmlTextWriter provides the WriteString method to assist you in writing string data as content. To ensure that the resulting XML is still well-formed, the WriteString method will perform the following tasks before writing the string:

  • The characters &, <, and > are replaced by &amp;, &lt;, and &gt;, respectively.

  • Character values in the range 0x0x1F are replaced by numeric character entries. White space characters with this range ...

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.