Imports System.Xml

 

Public Class Form1

 

    Dim coinsFilePath As String = "C:\xml L12 Finished\coin collection\coin collection.xml"

    Dim doc As XmlDocument

 

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

 

        Dim ElementList As XmlNodeList

        Dim IndividualElement As XmlNode

 

        Me.Text = "My Coin Collection"

 

        If Not My.Computer.FileSystem.FileExists(coinsFilePath) Then

            MsgBox("We were unable to open the coin collection XML file " & coinsFilePath)

            End

        End If

 

        doc = New XmlDocument()

        doc.Load(coinsFilePath)

 

        Dim s As String

 

        ElementList = doc.GetElementsByTagName("description")

 

        For Each IndividualElement In ElementList

            s = IndividualElement.InnerText

            lstDescriptions.Items.Add(s)

        Next IndividualElement

 

        lstDescriptions.SelectedIndex = 0

        Call lstDescriptions_Click(Me, e)

 

        txtSearch.Select()

 

    End Sub