Imports System
Imports System.Text
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
Dim output As StringBuilder = New StringBuilder()
Dim xmlString As String = "" & _
"" & _
"" & _
"- test with a child element stuff
" & _
""
Using reader As XmlReader = XmlReader.Create(New StringReader(xmlString))
Dim ws As XmlWriterSettings = New XmlWriterSettings()
ws.Indent = True
Using writer As XmlWriter = XmlWriter.Create(output, ws)
While reader.Read()
Select Case reader.NodeType
Case XmlNodeType.Element
writer.WriteStartElement(reader.Name)
Case XmlNodeType.Text
writer.WriteString(reader.Value)
Case XmlNodeType.XmlDeclaration
Case XmlNodeType.ProcessingInstruction
writer.WriteProcessingInstruction(reader.Name, reader.Value)
Case XmlNodeType.Comment
writer.WriteComment(reader.Value)
Case XmlNodeType.EndElement
writer.WriteFullEndElement()
End Select
End While
End Using
End Using
Console.WriteLine(output.ToString())
End Sub
End Class