XmlDocument.WriteTo(XmlWriter) Metoda

Definicja

XmlDocument Zapisuje węzeł w określonym XmlWriterobiekcie .

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)

Parametry

w
XmlWriter

Element XmlWriter , do którego chcesz zapisać.

Przykłady

Poniższy przykład przedstawia dokument na ekranie.

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

Uwagi

Ta metoda jest rozszerzeniem firmy Microsoft do modelu obiektów dokumentów (DOM). Jest ona funkcjonalnie równoważna OuterXml właściwości.

Właściwość XmlDeclaration.Encoding określa kodowanie, które zostało zapisane. Encoding Jeśli właściwość nie ma wartości, XmlDocument jest zapisywana bez atrybutu kodowania.

Dotyczy