XmlTextWriter.WriteRaw Metodo

Definizione

Scrive manualmente markup non elaborato.Writes raw markup manually.

Overload

WriteRaw(Char[], Int32, Int32)

Scrive manualmente markup non elaborato in base a un buffer di caratteri.Writes raw markup manually from a character buffer.

WriteRaw(String)

Scrive manualmente markup non elaborato in base a una stringa.Writes raw markup manually from a string.

Commenti

Nota

A partire da .NET Framework 2,0, è consigliabile creare istanze di XmlWriter usando il metodo XmlWriter.Create e la classe XmlWriterSettings per sfruttare le nuove funzionalità.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)

Scrive manualmente markup non elaborato in base a un buffer di caratteri.Writes raw markup manually from a character buffer.

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)

Parametri

buffer
Char[]

Matrice di caratteri che contiene il testo da scrivere.Character array containing the text to write.

index
Int32

Posizione all'interno del buffer che indica l'inizio del testo da scrivere.The position within the buffer indicating the start of the text to write.

count
Int32

Numero di caratteri da scrivere.The number of characters to write.

Eccezioni

buffer è null.buffer is null.

index o count è minore di zero.index or count is less than zero.

-oppure--or- La lunghezza del buffer meno index è minore di count.The buffer length minus index is less than count.

Commenti

Nota

A partire da .NET Framework 2,0, è consigliabile creare istanze di XmlWriter usando il metodo XmlWriter.Create e la classe XmlWriterSettings per sfruttare le nuove funzionalità.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.

Questo metodo non esegue l'escape di caratteri speciali.This method does not escape special characters.

Importante

Il XmlTextWriter non convalida i dati passati al metodo WriteRaw.The XmlTextWriter does not validate any data that is passed to the WriteRaw method. Non passare dati arbitrari a questo metodo.You should not pass arbitrary data to this method.

WriteRaw(String)

Scrive manualmente markup non elaborato in base a una stringa.Writes raw markup manually from a string.

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)

Parametri

data
String

Stringa contenente il testo da scrivere.String containing the text to write.

Esempio

Nell'esempio seguente viene scritta una stringa usando il metodo WriteRaw.The following example writes a string using the WriteRaw method.

#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

Commenti

Nota

A partire da .NET Framework 2,0, è consigliabile creare istanze di XmlWriter usando il metodo XmlWriter.Create e la classe XmlWriterSettings per sfruttare le nuove funzionalità.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.

Questo metodo non esegue l'escape di caratteri speciali.This method does not escape special characters.

Importante

Il XmlTextWriter non convalida i dati passati al metodo WriteRaw.The XmlTextWriter does not validate any data that is passed to the WriteRaw method. Non passare dati arbitrari a questo metodo.You should not pass arbitrary data to this method.

Si applica a