XmlTextWriter.WriteRaw Method

Definition

Writes raw markup manually.

Overloads

WriteRaw(Char[], Int32, Int32)

Writes raw markup manually from a character buffer.

WriteRaw(String)

Writes raw markup manually from a string.

Remarks

참고

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.

WriteRaw(Char[], Int32, Int32)

Source:
XmlTextWriter.cs
Source:
XmlTextWriter.cs
Source:
XmlTextWriter.cs

Writes raw markup manually from a character buffer.

public override void WriteRaw (char[] buffer, int index, int count);

Parameters

buffer
Char[]

Character array containing the text to write.

index
Int32

The position within the buffer indicating the start of the text to write.

count
Int32

The number of characters to write.

Exceptions

buffer is null.

index or count is less than zero.

-or-

The buffer length minus index is less than count.

Remarks

참고

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.

This method does not escape special characters.

중요

The XmlTextWriter does not validate any data that is passed to the WriteRaw method. You should not pass arbitrary data to this method.

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

WriteRaw(String)

Source:
XmlTextWriter.cs
Source:
XmlTextWriter.cs
Source:
XmlTextWriter.cs

Writes raw markup manually from a string.

public override void WriteRaw (string data);

Parameters

data
String

String containing the text to write.

Examples

The following example writes a string using the WriteRaw method.

using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {
     // Create a writer that outputs to the console.
     XmlTextWriter writer = new XmlTextWriter (Console.Out);
     writer.Formatting = Formatting.Indented;

     // Write the root element.
     writer.WriteStartElement("Items");

     // Write a string using WriteRaw. Note that the special
     // characters are not escaped.
     writer.WriteStartElement("Item");
     writer.WriteString("Write unescaped text:  ");
     writer.WriteRaw("this & that");
     writer.WriteEndElement();

     // Write the same string using WriteString. Note that the
     // special characters are escaped.
     writer.WriteStartElement("Item");
     writer.WriteString("Write the same string using WriteString:  ");
     writer.WriteString("this & that");
     writer.WriteEndElement();

     // Write the close tag for the root element.
     writer.WriteEndElement();

     // Write the XML to file and close the writer.
     writer.Close();
  }
}

Remarks

참고

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.

This method does not escape special characters.

중요

The XmlTextWriter does not validate any data that is passed to the WriteRaw method. You should not pass arbitrary data to this method.

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1