Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.IO
  2. Imports System.Xml
  3. Imports System.Xml.Serialization
  4. Imports System.Text
  5.  
  6.  
  7. Public Class formMain
  8.  
  9.     Private xdDoc As New XmlDocument() 'Create Modular XMLDocument Object
  10.  
  11.     Private Sub formMain_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
  12.         If My.Computer.FileSystem.FileExists("data.xml") = False Then
  13.  
  14.             xdDoc.LoadXml("<Student><Name>Bobby</Name><Grade>A Grade</Grade><Status>Fully Paid</Status></Student>")
  15.  
  16.             Dim xtwWriter As New XmlTextWriter("data.xml", Nothing)
  17.  
  18.             xtwWriter.Formatting = Formatting.Indented
  19.             xdDoc.Save(xtwWriter)
  20.  
  21.             xtwWriter.Close()
  22.         End If
  23.  
  24.         'Read XML File
  25.        Dim xtrReader As New XmlTextReader("data.xml")
  26.         Dim sbReadXML As New StringBuilder 'Create StringBuilder Object To Host Contents
  27.  
  28.         While xtrReader.Read() 'While The Reader Is Reading The Data
  29.                    sbReadXML.Append(xtrReader.ReadOuterXml)
  30.         End While
  31.  
  32.         xdDoc.LoadXml(sbReadXML.ToString())
  33.  
  34.         TextBox1.Text = xdDoc.ChildNodes(0).ChildNodes(0).FirstChild.Value
  35.     End Sub
  36. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement