This documentation is archived and is not being maintained.

XmlWriter.WriteString Method

When overridden in a derived class, writes the given text content.

[Visual Basic]
Public MustOverride Sub WriteString( _
   ByVal text As String _
public abstract void WriteString(
 string text
public: virtual void WriteString(
 String* text
) = 0;
public abstract function WriteString(
   text : String


The text to write.


Exception Type Condition
ArgumentException The text string contains an invalid surrogate pair.


WriteString does the following

  • The characters &, <, and > are replaced with &amp;, &lt;, and &gt;, respectively.
  • Character values in the range 0x-0x1F (excluding white space characters 0x9, 0x10, and 0x13) are replaced with numeric character entities (&#0; through &#0x1F).
  • If WriteString is called in the context of an attribute value, double and single quotes are replaced with &quot; and &apos; respectively.

For example, this input string test<item>test is written out as


If text is either a null reference (Nothing in Visual Basic) or String.Empty, this method writes a text node with no data content.


See WriteString (in the XmlTextWriter class) for an example using this method.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

XmlWriter Class | XmlWriter Members | System.Xml Namespace