System.Xml.XmlWriter.WriteString Method

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

Syntax

public abstract void WriteString (string text)

Parameters

text
The text to write.

Exceptions

TypeReason
InvalidOperationExceptionThe XmlWriter.WriteState is WriteState.Closed.

Remarks

WriteString does the following:

Note   Microsoft does not encourage the practice of writing invalid XML characters since many applications that consume XML are not designed to handle invalid characters.

  • If WriteString is called in the context of an attribute value, double and single quotes are replaced with " and ' respectively.

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

Example

 test&lt;item&gt;test

If text is either null or String.Empty, this method writes a text node with no data content.

For the asynchronous version of this method, see XmlWriter.WriteStringAsync(string).

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0