O'Reilly logo

Microsoft® .NET Compact Framework Kick Start by Ronnie Yates, Erik Rubin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing Other Nodes

In most cases your XML will consist of only elements and attributes, but there are situations where you may need to add comments, CDATA, or other uncommon nodes to your XML document.

Writing Comments

Let's first look at writing comments. Comments can appear anywhere in the document after the prolog (everything before the root element) and even in the epilog (everything after the root element). Although the W3C XML specification states that a comment may appear anywhere in the document, even before the prolog, this is not true for documents created by the XmlTextWriter. Attempting to write a comment before writing an XML declaration will result in an InvalidOperationException. Listing 10.33 demonstrates how to add a comment ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required