XmlTextWriter.WriteComment Method (String)


Writes out a comment <!--...--> containing the specified text.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

override WriteComment : 
        text:string -> unit


Type: System.String

Text to place inside the comment.

Exception Condition

The text would result in a non-well formed XML document


The WriteState is Closed.


Starting with the .NET Framework 2.0, we recommend that you create XmlWriter instances by using the XmlWriter.Create method and the XmlWriterSettings class to take advantage of new functionality.

If text is either null or String.Empty, this method writes a Comment with no data content, for example <!---->.

The following example writes an XML file representing a book.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top