Imports System.Text

Imports System.Xml

 

Public Class Form1

 

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

 

        Dim SAXFilePath As String = "C:\xml L12 Finished\SAX Example\SAXExample.xml"

        Dim XWriter As XmlTextWriter

 

        XWriter = New XmlTextWriter(SAXFilePath, Encoding.UTF8)

 

        XWriter.WriteStartDocument(True)

        XWriter.WriteStartElement("fruit")

        XWriter.WriteStartElement("first")

        XWriter.WriteString("apples")

        XWriter.WriteEndElement()

        XWriter.WriteStartElement("second")

        XWriter.WriteString("oranges")

        XWriter.WriteEndElement()

        XWriter.WriteStartElement("third")

        XWriter.WriteString("bananas")

        XWriter.WriteEndElement()

        XWriter.WriteEndElement()

 

        XWriter.WriteEndDocument()

        XWriter.Close()

        MsgBox(IO.File.ReadAllText(SAXFilePath))

 

        End

 

    End Sub

End Class