XmlDocument.PreserveWhitespace Özellik
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Öğe içeriğinde boşluk korunup korunmayacağını belirten bir değer alır veya ayarlar.
public:
property bool PreserveWhitespace { bool get(); void set(bool value); };
public bool PreserveWhitespace { get; set; }
member this.PreserveWhitespace : bool with get, set
Public Property PreserveWhitespace As Boolean
true
boşluğu korumak için; aksi takdirde false
. Varsayılan değer: false
.
Aşağıdaki örnekte, bir dosyadaki boşlukların nasıl şeritle alınacakları gösterilmektedir.
#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 );
}
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);
}
}
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
Örnek, giriş olarak dosyasını book.xml
kullanır.
<!--sample XML fragment-->
<book genre='novel' ISBN='1-861003-78' misc='sale-item'>
<title>The Handmaid's Tale</title>
<price>14.95</price>
</book>
Bu özellik, yükleme ve kaydetme işlemi sırasında boşluğun nasıl işleneceğini belirler.
Önceyse veya çağrılırsaPreserveWhitespace
, boşluk düğümleri korunur; aksi takdirde, bu özellik false
ise, önemli boşluk korunur, boşluk korunmaz.LoadXmltrue
Load
true
Önce çağrılırsaPreserveWhitespace
, belgedeki boşluk çıktıda korunur; aksi takdirde, bu özellik ise XmlDocument
false
çıkışı otomatik olarak girintilerSave.
Bu yöntem, Belge Nesne Modeli'nin (DOM) Microsoft bir uzantısıdır.
Ürün | Sürümler |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
UWP | 10.0 |
.NET geri bildirimi
.NET, açık kaynak bir projedir. Geri bildirim sağlamak için bir bağlantı seçin: