XmlTextWriter.WriteRaw Método

Definição

Grava a marcação bruta manualmente.

Sobrecargas

Nome Description
WriteRaw(Char[], Int32, Int32)

Grava a marcação bruta manualmente de um buffer de caracteres.

WriteRaw(String)

Grava a marcação bruta manualmente de uma cadeia de caracteres.

Comentários

Note

Recomendamos que você crie XmlWriter instâncias usando o XmlWriter.Create método e a XmlWriterSettings classe para aproveitar a nova funcionalidade.

WriteRaw(Char[], Int32, Int32)

Grava a marcação bruta manualmente de um buffer de caracteres.

public:
 override void WriteRaw(cli::array <char> ^ buffer, int index, int count);
public override void WriteRaw(char[] buffer, int index, int count);
override this.WriteRaw : char[] * int * int -> unit
Public Overrides Sub WriteRaw (buffer As Char(), index As Integer, count As Integer)

Parâmetros

buffer
Char[]

Matriz de caracteres que contém o texto a ser gravado.

index
Int32

A posição dentro do buffer que indica o início do texto a ser gravado.

count
Int32

O número de caracteres a serem gravados.

Exceções

buffer é null.

index ou count é menor que zero.

-ou-

O tamanho do buffer menos index é menor que count.

Comentários

Note

Recomendamos que você crie XmlWriter instâncias usando o XmlWriter.Create método e a XmlWriterSettings classe para aproveitar a nova funcionalidade.

Esse método não escapa de caracteres especiais.

Importante

Os XmlTextWriter dados não são validados que são passados para o WriteRaw método. Você não deve passar dados arbitrários para esse método.

Aplica-se a

WriteRaw(String)

Grava a marcação bruta manualmente de uma cadeia de caracteres.

public:
 override void WriteRaw(System::String ^ data);
public override void WriteRaw(string data);
override this.WriteRaw : string -> unit
Public Overrides Sub WriteRaw (data As String)

Parâmetros

data
String

Cadeia de caracteres que contém o texto a ser gravado.

Exemplos

O exemplo a seguir grava uma cadeia de caracteres usando o WriteRaw método.

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();
  }
}
Option Strict
Option Explicit

Imports System.IO
Imports System.Xml

Public Class Sample
    
    Public Shared Sub Main()
        ' Create a writer that outputs to the console.
        Dim writer As 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()
    End Sub
End Class

Comentários

Note

Recomendamos que você crie XmlWriter instâncias usando o XmlWriter.Create método e a XmlWriterSettings classe para aproveitar a nova funcionalidade.

Esse método não escapa de caracteres especiais.

Importante

Os XmlTextWriter dados não são validados que são passados para o WriteRaw método. Você não deve passar dados arbitrários para esse método.

Aplica-se a