XmlTextWriter.WriteRaw Método

Definição

Escreve a marcação bruta manualmente.

Sobrecargas

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

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

WriteRaw(String)

Escreve a marcação bruta manualmente a partir de uma cadeia.

Observações

Note

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

WriteRaw(Char[], Int32, Int32)

Origem:
XmlTextWriter.cs
Origem:
XmlTextWriter.cs
Origem:
XmlTextWriter.cs
Origem:
XmlTextWriter.cs
Origem:
XmlTextWriter.cs

Escreve a marcação bruta manualmente a partir 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[]

Array de caracteres contendo o texto a escrever.

index
Int32

A posição dentro do buffer indica o início do texto a escrever.

count
Int32

O número de caracteres a escrever.

Exceções

buffer é null.

index ou count é inferior a zero.

-ou-

O comprimento do buffer menos index é menor que count.

Observações

Note

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

Este método não escapa a caracteres especiais.

Importante

Não XmlTextWriter valida quaisquer dados que sejam passados ao WriteRaw método. Não deve passar dados arbitrários a este método.

Aplica-se a

WriteRaw(String)

Origem:
XmlTextWriter.cs
Origem:
XmlTextWriter.cs
Origem:
XmlTextWriter.cs
Origem:
XmlTextWriter.cs
Origem:
XmlTextWriter.cs

Escreve a marcação bruta manualmente a partir de uma cadeia.

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

String contendo o texto a escrever.

Exemplos

O exemplo seguinte escreve uma cadeia 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

Observações

Note

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

Este método não escapa a caracteres especiais.

Importante

Não XmlTextWriter valida quaisquer dados que sejam passados ao WriteRaw método. Não deve passar dados arbitrários a este método.

Aplica-se a