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.
Ruft einen XmlSpace ab, der den aktuellen xml:space-Bereich darstellt.
Namespace: System.Xml
Assembly: System.Xml (in system.xml.dll)
Syntax
'Declaration
Public Overrides ReadOnly Property XmlSpace As XmlSpace
'Usage
Dim instance As XmlTextWriter
Dim value As XmlSpace
value = instance.XmlSpace
public override XmlSpace XmlSpace { get; }
public:
virtual property XmlSpace XmlSpace {
XmlSpace get () override;
}
/** @property */
public XmlSpace get_XmlSpace ()
public override function get XmlSpace () : XmlSpace
Eigenschaftenwert
Ein XmlSpace, der den aktuellen xml:space-Bereich darstellt.
Wert |
Bedeutung |
|---|---|
Keiner |
Dies ist der Standardwert, wenn kein xml:space-Bereich vorhanden ist. |
Standardwert |
Der aktuelle Bereich ist xml:space="default". |
Preserve |
Der aktuelle Bereich ist xml:space="preserve". |
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.
Mit dieser Eigenschaft kann eine Komponente ermitteln, in welchem Zustand eine andere Komponente den Writer verlassen hat.
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