XmlDocument.PreserveWhitespace プロパティ
アセンブリ: System.Xml (system.xml.dll 内)
構文
Dim instance As XmlDocument Dim value As Boolean value = instance.PreserveWhitespace instance.PreserveWhitespace = value
/** @property */ public boolean get_PreserveWhitespace () /** @property */ public void set_PreserveWhitespace (boolean value)
public function get PreserveWhitespace () : boolean public function set PreserveWhitespace (value : boolean)
空白である場合は true。それ以外の場合は false。既定値は false です。
このプロパティは、読み込みおよび保存プロセス中の空白の処理方法を決定します。
Load または LoadXml が呼び出される前に PreserveWhitespace が true の場合、空白ノードは保存されます。このプロパティが false の場合、有意な空白は保存されますが、空白は保存されません。
Save が呼び出される前に PreserveWhitespace が true の場合、ドキュメント内の空白は出力で保存されます。このプロパティが false の場合、XmlDocument は出力に自動的にインデントを設定します。
このメソッドは、DOM (Document Object Model) に対する Microsoft 拡張機能です。
Imports System Imports System.IO Imports System.Xml public class Sample public shared sub Main() 'Load XML data which includes white space, but ignore 'any white space in the file. Dim doc as XmlDocument = new XmlDocument() doc.PreserveWhitespace = false doc.Load("book.xml") 'Save the document as is (no white space). Console.WriteLine("Display the modified XML...") doc.PreserveWhitespace = true doc.Save(Console.Out) end sub end class
using System; using System.IO; using System.Xml; public class Sample { public static void Main() { //Load XML data which includes white space, but ignore //any white space in the file. XmlDocument doc = new XmlDocument(); doc.PreserveWhitespace = false; doc.Load("book.xml"); //Save the document as is (no white space). Console.WriteLine("Display the modified XML..."); doc.PreserveWhitespace = true; doc.Save(Console.Out); } }
#using <System.Xml.dll> using namespace System; using namespace System::IO; using namespace System::Xml; int main() { //Load XML data which includes white space, but ignore //any white space in the file. XmlDocument^ doc = gcnew XmlDocument; doc->PreserveWhitespace = false; doc->Load( "book.xml" ); //Save the document as is (no white space). Console::WriteLine( "Display the modified XML..." ); doc->PreserveWhitespace = true; doc->Save( Console::Out ); }
import System.*; import System.IO.*; import System.Xml.*; public class Sample { public static void main(String[] args) { // Load XML data which includes white space, but ignore // any white space in the file. XmlDocument doc = new XmlDocument(); doc.set_PreserveWhitespace(false); doc.Load("book.xml"); // Save the document as is (no white space). Console.WriteLine("Display the modified XML..."); doc.set_PreserveWhitespace(true); doc.Save(Console.get_Out()); } //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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- XmlDocument.PreserveWhitespace プロパティのページへのリンク