共用方式為


XmlDocument.WriteTo(XmlWriter) 方法

定義

XmlDocument 節點儲存至指定的 XmlWriter

public:
 override void WriteTo(System::Xml::XmlWriter ^ w);
public override void WriteTo (System.Xml.XmlWriter w);
override this.WriteTo : System.Xml.XmlWriter -> unit
Public Overrides Sub WriteTo (w As XmlWriter)

參數

w
XmlWriter

要儲存的目標 XmlWriter

範例

下列範例會顯示幕幕上的檔。

void WriteXml( XmlDocument^ doc )
{
   XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out );
   writer->Formatting = Formatting::Indented;
   doc->WriteTo( writer );
   writer->Flush();
   Console::WriteLine();
}

public static void WriteXml( XmlDocument doc )
 {
    XmlTextWriter writer = new XmlTextWriter(Console.Out);
    writer.Formatting = Formatting.Indented;
    doc.WriteTo( writer );
    writer.Flush();
    Console.WriteLine();
 }
Public Shared Sub WriteXml(doc As XmlDocument)
    Dim writer As New XmlTextWriter(Console.Out)
    writer.Formatting = Formatting.Indented
    doc.WriteTo(writer)
    writer.Flush()
    Console.WriteLine()
End Sub

備註

此方法是檔物件模型 (DOM) 的 Microsoft 延伸模組。 它的功能相當於 OuterXml 屬性。

屬性 XmlDeclaration.Encoding 會決定寫出的編碼方式。 Encoding 如果屬性沒有值,則會 XmlDocument 在沒有編碼屬性的情況下寫出 。

適用於