XmlTextWriter.WriteRaw Méthode

Définition

Écrit manuellement un balisage brut.Writes raw markup manually.

Surcharges

WriteRaw(Char[], Int32, Int32)

Écrit manuellement un balisage brut à partir d'une mémoire tampon de caractères.Writes raw markup manually from a character buffer.

WriteRaw(String)

Écrit manuellement un balisage brut à partir d'une chaîne.Writes raw markup manually from a string.

Remarques

Notes

À partir de la .NET Framework 2,0, nous vous recommandons de créer XmlWriter des instances à l’aide XmlWriter.Create de la méthode et de la XmlWriterSettings classe pour tirer parti des nouvelles fonctionnalités.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)

Écrit manuellement un balisage brut à partir d'une mémoire tampon de caractères.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)

Paramètres

buffer
Char[]

Tableau de caractères contenant le texte à écrire.Character array containing the text to write.

index
Int32

Emplacement dans la mémoire tampon indiquant le début du texte à écrire.The position within the buffer indicating the start of the text to write.

count
Int32

Nombre de caractères à écrire.The number of characters to write.

Exceptions

buffer a la valeur null.buffer is null.

index ou count est inférieur à zéro.index or count is less than zero.

- ou --or- La longueur de la mémoire tampon moins index est inférieure à count.The buffer length minus index is less than count.

Remarques

Notes

À partir de la .NET Framework 2,0, nous vous recommandons de créer XmlWriter des instances à l’aide XmlWriter.Create de la méthode et de la XmlWriterSettings classe pour tirer parti des nouvelles fonctionnalités.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.

Cette méthode n’échappe pas les caractères spéciaux.This method does not escape special characters.

Important

XmlTextWriterNe valide pas les données passées à la WriteRaw méthode.The XmlTextWriter does not validate any data that is passed to the WriteRaw method. Vous ne devez pas passer de données arbitraires à cette méthode.You should not pass arbitrary data to this method.

WriteRaw(String)

Écrit manuellement un balisage brut à partir d'une chaîne.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)

Paramètres

data
String

Chaîne contenant le texte à écrire.String containing the text to write.

Exemples

L’exemple suivant écrit une chaîne à l’aide de la WriteRaw méthode.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

Remarques

Notes

À partir de la .NET Framework 2,0, nous vous recommandons de créer XmlWriter des instances à l’aide XmlWriter.Create de la méthode et de la XmlWriterSettings classe pour tirer parti des nouvelles fonctionnalités.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.

Cette méthode n’échappe pas les caractères spéciaux.This method does not escape special characters.

Important

XmlTextWriterNe valide pas les données passées à la WriteRaw méthode.The XmlTextWriter does not validate any data that is passed to the WriteRaw method. Vous ne devez pas passer de données arbitraires à cette méthode.You should not pass arbitrary data to this method.

S’applique à