Writes the specified text.
- text
- A string specifying the text to write.
Type Reason InvalidOperationException The XmlTextWriter.WriteState is WriteState.Closed and text is neither null nor string.Empty.
This method performs the following conversions before writing the text:
- The characters '&', '<', and '>' are replaced with "&", "<", and ">", respectively.
- Character values in the range 0x-0x1F (excluding the white space characters 0x9, 0x10, and 0x13) are replaced with numeric character entities ("�" through "�x1F").
- If called in the context of an attribute value, double and single quotes are replaced with """ and "'" respectively.
If text is null or string.Empty, this method writes a text node with no data content.
Note:This method overrides XmlWriter.WriteString(string).
The following example demonstrates the conversions performed by this method.
C# Example
using System; using System.Xml; public class WriteFrag { public static void Main() { XmlTextWriter xtWriter = new XmlTextWriter(Console.Out); xtWriter.WriteString("<1 & 2 = 3>"); } }The output is
<1 & 2 = 3>
Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0