XmlTextWriter.XmlSpace プロパティ
アセンブリ: System.Xml (system.xml.dll 内)



WriteWhitespace メソッドを使用して、ファイルを書式設定する方法を制御する例を次に示します。
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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からXmlTextWriter.XmlSpace プロパティを検索する場合は、下記のリンクをクリックしてください。

- XmlTextWriter.XmlSpace プロパティのページへのリンク