Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Schreibt den angegebenen Leerraum.
Namespace: System.Xml
Assembly: System.Xml (in system.xml.dll)
Syntax
'Declaration
Public Overrides Sub WriteWhitespace ( _
ws As String _
)
'Usage
Dim instance As XmlTextWriter
Dim ws As String
instance.WriteWhitespace(ws)
public override void WriteWhitespace (
string ws
)
public:
virtual void WriteWhitespace (
String^ ws
) override
public void WriteWhitespace (
String ws
)
public override function WriteWhitespace (
ws : String
)
Parameter
- ws
Die Zeichenfolge von Leerraumzeichen.
Ausnahmen
| Ausnahmetyp | Bedingung |
|---|---|
Die Zeichenfolge enthält Zeichen, die keine Leerraumzeichen sind. |
Hinweise
Hinweis
Die empfohlene Vorgehensweise für die Version Microsoft .NET Framework, Version 2.0 besteht darin, mithilfe der System.Xml.XmlWriter.Create-Methode und der XmlWriterSettings-Klasse XmlWriter-Instanzen zu erstellen. So können Sie alle neuen Features dieser Version in vollem Umfang nutzen. Weitere Informationen finden Sie unter Erstellen von XML-Writern.
Diese Methode wird zum manuellen Formatieren des Dokuments verwendet. Wenn der Writer die Ausgabe automatisch formatieren soll, verwenden Sie die Formatting-Eigenschaft.
Beispiel
Im folgenden Beispiel wird mit der WriteWhitespace-Methode die Formatierung der Datei gesteuert.
Option Strict
Option Explicit
Imports System
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
' Create the writer.
Dim writer As XmlTextWriter = Nothing
writer = New XmlTextWriter("ws.html", Nothing)
' Write an element (this one is the root).
writer.WriteStartElement("p")
' Write the xml:space attribute.
writer.WriteAttributeString("xml", "space", Nothing, "preserve")
' Verify that xml:space is set properly.
If writer.XmlSpace = XmlSpace.Preserve Then
Console.WriteLine("xmlspace is correct!")
End If
' 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()
End Sub 'Main
End Class 'Sample
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();
}
}
#using <System.Xml.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
// Create the writer.
XmlTextWriter^ writer = nullptr;
writer = gcnew XmlTextWriter( "ws.html", nullptr );
// Write an element (this one is the root).
writer->WriteStartElement( "p" );
// Write the xml:space attribute.
writer->WriteAttributeString( "xml", "space", nullptr, "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();
}
import System.*;
import System.IO.*;
import System.Xml.*;
public class Sample
{
public static void main(String[] args)
{
// 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.get_XmlSpace().Equals(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();
} //main
} //Sample
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0, 1.0
Siehe auch
Referenz
XmlTextWriter-Klasse
XmlTextWriter-Member
System.Xml-Namespace
Formatting