XmlDocument.WriteContentTo(XmlWriter) 方法

定義

XmlDocument 節點的所有子系儲存到指定的 XmlWriter

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

參數

xw
XmlWriter

要儲存的目標 XmlWriter

範例

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

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

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

備註

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

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

適用於