WriteTo Method

XmlNode.WriteTo Method (XmlWriter)

 

Saves the current node to the specified XmlWriter, when overridden in a derived class.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

Public MustOverride Sub WriteTo (
	w As XmlWriter
)

Parameters

w
Type: System.Xml.XmlWriter

The XmlWriter to which you want to save.

This method is a Microsoft extension to the Document Object Model (DOM). It is functionally equivalent to the OuterXml property.

The following example displays the root node to the console.

Option Explicit
Option Strict

Imports System
Imports System.IO
Imports System.Xml

Public Class Sample

    Public Shared Sub Main()

        Dim doc As New XmlDocument()
        doc.LoadXml("<book xmlns:bk='urn:samples' bk:ISBN='1-861001-57-5'>" & _
                    "<title>Pride And Prejudice</title>" & _
                    "</book>")

        Dim root As XmlNode = doc.FirstChild

        Console.WriteLine("Display the root node...")
        Dim writer As New XmlTextWriter(Console.Out)
        writer.Formatting = Formatting.Indented
        root.WriteTo(writer)
    End Sub 'Main 
End Class 'Sample

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft