XDocument.Save Method (XmlWriter) serializes this XDocument to an XmlWriter.
Imports System
Imports System.Text
Imports System.Xml
Imports System.Xml.XPath
Public Class MainClass
Public Shared Sub Main()
Dim sb As StringBuilder = New StringBuilder()
Dim xws As XmlWriterSettings = New XmlWriterSettings()
xws.OmitXmlDeclaration = True
xws.Indent = True
Using xw = XmlWriter.Create(sb, xws)
Dim doc As XDocument = New XDocument(<Child><GrandChild>some content</GrandChild></Child>)
doc.Save(xw)
End Using
Console.WriteLine(sb.ToString())
End Sub
End Class