Compartir a través de


XmlTextWriter.WriteRaw Método

Definición

Escribe manualmente el marcado sin formato.

Sobrecargas

WriteRaw(Char[], Int32, Int32)

Escribe manualmente el marcado sin formato de un búfer de caracteres.

WriteRaw(String)

Escribe manualmente el marcado sin formato de una cadena.

Comentarios

Nota

A partir de .NET Framework 2.0, se recomienda crear XmlWriter instancias mediante el XmlWriter.Create método y la XmlWriterSettings clase para aprovechar las nuevas funcionalidades.

WriteRaw(Char[], Int32, Int32)

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

Escribe manualmente el marcado sin formato de un búfer 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 contiene el texto que se va a escribir.

index
Int32

Posición en el búfer que indica el inicio del texto que se va a escribir.

count
Int32

Número de caracteres que se van a escribir.

Excepciones

buffer es null.

index o count es menor que cero.

o bien

La longitud del búfer menos index es menor que count.

Comentarios

Nota

A partir de .NET Framework 2.0, se recomienda crear XmlWriter instancias mediante el XmlWriter.Create método y la XmlWriterSettings clase para aprovechar las nuevas funcionalidades.

Este método no aplica caracteres especiales de escape.

Importante

XmlTextWriter no valida ningún dato que se pase al WriteRaw método . No debe pasar datos arbitrarios a este método.

Se aplica a

WriteRaw(String)

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

Escribe manualmente el marcado sin formato de una cadena.

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

Cadena que contiene el texto que se va a escribir.

Ejemplos

En el ejemplo siguiente se escribe una cadena mediante el WriteRaw método .

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   
   // Create a writer that outputs to the console.
   XmlTextWriter^ writer = gcnew 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();
}
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

Comentarios

Nota

A partir de .NET Framework 2.0, se recomienda crear XmlWriter instancias mediante el XmlWriter.Create método y la XmlWriterSettings clase para aprovechar las nuevas funcionalidades.

Este método no aplica caracteres especiales de escape.

Importante

XmlTextWriter no valida ningún dato que se pase al WriteRaw método . No debe pasar datos arbitrarios a este método.

Se aplica a