Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Imports System.Xml
- Imports System.Xml.Serialization
- Imports System.Text
- Public Class formMain
- Private xdDoc As New XmlDocument() 'Create Modular XMLDocument Object
- Private Sub formMain_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
- If My.Computer.FileSystem.FileExists("data.xml") = False Then
- xdDoc.LoadXml("<Student><Name>Bobby</Name><Grade>A Grade</Grade><Status>Fully Paid</Status></Student>")
- Dim xtwWriter As New XmlTextWriter("data.xml", Nothing)
- xtwWriter.Formatting = Formatting.Indented
- xdDoc.Save(xtwWriter)
- xtwWriter.Close()
- End If
- 'Read XML File
- Dim xtrReader As New XmlTextReader("data.xml")
- Dim sbReadXML As New StringBuilder 'Create StringBuilder Object To Host Contents
- While xtrReader.Read() 'While The Reader Is Reading The Data
- sbReadXML.Append(xtrReader.ReadOuterXml)
- End While
- xdDoc.LoadXml(sbReadXML.ToString())
- TextBox1.Text = xdDoc.ChildNodes(0).ChildNodes(0).FirstChild.Value
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement