XmlWriter.Close closes this stream and the underlying stream.
Option Explicit Option Strict Imports System Imports System.IO Imports System.Xml Public Class Sample Public Shared Sub Main() Dim settings As XmlWriterSettings = new XmlWriterSettings() settings.Indent = true settings.OmitXmlDeclaration = true Dim writer As XmlWriter = XmlWriter.Create(Console.Out, settings) writer.WriteStartElement("book") writer.WriteStartElement("title") writer.WriteString("C#") writer.WriteEndElement() writer.WriteEndElement() writer.Close() End Sub 'Main End Class 'Sample