XmlTextWriter.WriteRaw Metodo

Definizione

Scrive manualmente markup non elaborato.

Overload

WriteRaw(Char[], Int32, Int32)

Scrive manualmente markup non elaborato in base a un buffer di caratteri.

WriteRaw(String)

Scrive manualmente markup non elaborato in base a una stringa.

Commenti

Nota

A partire da .NET Framework 2.0, è consigliabile creare XmlWriter istanze usando il metodo e la XmlWriter.CreateXmlWriterSettings classe per sfruttare nuove funzionalità.

WriteRaw(Char[], Int32, Int32)

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

Scrive manualmente markup non elaborato in base a un buffer di caratteri.

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.

index
Int32

Posizione all'interno del buffer che indica l'inizio del testo da scrivere.

count
Int32

Numero di caratteri da scrivere.

Eccezioni

buffer è null.

index o count è minore di zero.

-oppure-

La lunghezza del buffer meno index è minore di count.

Commenti

Nota

A partire da .NET Framework 2.0, è consigliabile creare XmlWriter istanze usando il metodo e la XmlWriter.CreateXmlWriterSettings classe per sfruttare nuove funzionalità.

Questo metodo non esegue l'escape di caratteri speciali.

Importante

Non XmlTextWriter convalida i dati passati al WriteRaw metodo. Non è consigliabile passare dati arbitrari a questo metodo.

Si applica a

WriteRaw(String)

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

Scrive manualmente markup non elaborato in base a una stringa.

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.

Esempio

Nell'esempio seguente viene usata una stringa usando il WriteRaw metodo .

#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 XmlWriter istanze usando il metodo e la XmlWriter.CreateXmlWriterSettings classe per sfruttare nuove funzionalità.

Questo metodo non esegue l'escape di caratteri speciali.

Importante

Non XmlTextWriter convalida i dati passati al WriteRaw metodo. Non è consigliabile passare dati arbitrari a questo metodo.

Si applica a