XmlTextWriter.WriteRaw Metoda

Definicja

Zapisuje nieprzetworzone znaczniki ręcznie.

Przeciążenia

WriteRaw(Char[], Int32, Int32)

Zapisuje nieprzetworzone znaczniki ręcznie z buforu znaków.

WriteRaw(String)

Zapisuje nieprzetworzone znaczniki ręcznie z ciągu.

Uwagi

Uwaga

Począwszy od .NET Framework 2.0, zalecamy utworzenie XmlWriter wystąpień przy użyciu metody i XmlWriterSettings klasy, aby korzystać z XmlWriter.Create nowych funkcji.

WriteRaw(Char[], Int32, Int32)

Zapisuje nieprzetworzone znaczniki ręcznie z buforu znaków.

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)

Parametry

buffer
Char[]

Tablica znaków zawierająca tekst do zapisu.

index
Int32

Pozycja w buforze wskazująca początek tekstu do zapisu.

count
Int32

Liczba znaków, jaka ma zostać zapisana.

Wyjątki

buffer to null.

index wartość lub count jest mniejsza niż zero.

-lub- Długość buforu minus index jest mniejsza niż count.

Uwagi

Uwaga

Począwszy od .NET Framework 2.0, zalecamy utworzenie XmlWriter wystąpień przy użyciu metody i XmlWriterSettings klasy, aby korzystać z XmlWriter.Create nowych funkcji.

Ta metoda nie powoduje ucieczki znaków specjalnych.

Ważne

Element XmlTextWriter nie weryfikuje żadnych danych przekazywanych do WriteRaw metody. Nie należy przekazywać dowolnych danych do tej metody.

Dotyczy

WriteRaw(String)

Zapisuje nieprzetworzone znaczniki ręcznie z ciągu.

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)

Parametry

data
String

Ciąg zawierający tekst do zapisania.

Przykłady

Poniższy przykład zapisuje ciąg przy użyciu WriteRaw metody .

#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

Uwagi

Uwaga

Począwszy od .NET Framework 2.0, zalecamy utworzenie XmlWriter wystąpień przy użyciu metody i XmlWriterSettings klasy, aby korzystać z XmlWriter.Create nowych funkcji.

Ta metoda nie powoduje ucieczki znaków specjalnych.

Ważne

Element XmlTextWriter nie weryfikuje żadnych danych przekazywanych do WriteRaw metody. Nie należy przekazywać dowolnych danych do tej metody.

Dotyczy