XmlTextWriter.WriteRaw Méthode

Définition

Écrit manuellement le balisage brut.

Surcharges

Nom Description
WriteRaw(Char[], Int32, Int32)

Écrit manuellement le balisage brut à partir d’une mémoire tampon de caractères.

WriteRaw(String)

Écrit manuellement le balisage brut à partir d’une chaîne.

Remarques

Note

Nous vous recommandons de créer XmlWriter instances en utilisant la méthode XmlWriter.Create et la classe XmlWriterSettings pour tirer parti de nouvelles fonctionnalités.

WriteRaw(Char[], Int32, Int32)

Écrit manuellement le balisage brut à partir d’une mémoire tampon de caractères.

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.

index
Int32

Position dans la mémoire tampon indiquant le début du texte à écrire.

count
Int32

Nombre de caractères à écrire.

Exceptions

buffer a la valeur null.

index ou count est inférieur à zéro.

-ou-

La longueur de la mémoire tampon moins index est inférieure à count.

Remarques

Note

Nous vous recommandons de créer XmlWriter instances en utilisant la méthode XmlWriter.Create et la classe XmlWriterSettings pour tirer parti de nouvelles fonctionnalités.

Cette méthode n’échappe pas aux caractères spéciaux.

Important

Il XmlTextWriter ne valide pas les données passées à la WriteRaw méthode. Vous ne devez pas transmettre de données arbitraires à cette méthode.

S’applique à

WriteRaw(String)

Écrit manuellement le balisage brut à partir d’une chaîne.

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.

Exemples

L’exemple suivant écrit une chaîne à l’aide de la WriteRaw méthode.

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

Note

Nous vous recommandons de créer XmlWriter instances en utilisant la méthode XmlWriter.Create et la classe XmlWriterSettings pour tirer parti de nouvelles fonctionnalités.

Cette méthode n’échappe pas aux caractères spéciaux.

Important

Il XmlTextWriter ne valide pas les données passées à la WriteRaw méthode. Vous ne devez pas transmettre de données arbitraires à cette méthode.

S’applique à