WriteWhitespace Méthode (String)
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
Traduction
Source

XmlTextWriter.WriteWhitespace, méthode (String)

 

Écrit l'espace blanc spécifié

Espace de noms:   System.Xml
Assembly:  System.Xml (dans System.Xml.dll)

public override void WriteWhitespace(
	string ws
)

Paramètres

ws

Chaîne d'espaces blancs.

Exception Condition
ArgumentException

The string contains non-white space characters.

System_CAPS_noteRemarque

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.

This method is used to manually format your document.Use the Formatting property to have the writer format the output automatically.

The following example uses the WriteWhitespace method to control how the file is formatted.

using System;
using System.IO;
using System.Xml;

public class Sample
{  
  public static void Main()
  {
    // Create the writer.
    XmlTextWriter writer = null;
    writer = new XmlTextWriter ("ws.html", null);

    // Write an element (this one is the root).
    writer.WriteStartElement("p");

    // Write the xml:space attribute.
    writer.WriteAttributeString("xml", "space", null, "preserve");

    // Verify that xml:space is set properly.
    if (writer.XmlSpace == XmlSpace.Preserve)
      Console.WriteLine("xmlspace is correct!");

    // Write out the HTML elements.  Insert white space
    // between 'something' and 'Big'
    writer.WriteString("something");
    writer.WriteWhitespace("  ");
    writer.WriteElementString("b", "B");
    writer.WriteString("ig");

    // Write the root end element.
    writer.WriteEndElement();

    // Write the XML to file and close the writer.
    writer.Close();  
  }
}

.NET Framework
Disponible depuis 1.1
Retour au début
Afficher:
© 2016 Microsoft