共用方式為


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你想要節省的金額。

範例

以下範例展示了該文件。

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

備註

此方法是 Microsoft 對文件物件模型(DOM)的擴充。 它在功能上等同於該 OuterXml 性質。

屬性決定 XmlDeclaration.Encoding 了所寫出的編碼。若屬性 Encoding 沒有值, XmlDocument 則會寫出不包含編碼屬性的屬性。

適用於