AWorkTool 0 Newbie Poster

I am building a tool for my team at work to search a XML file for a particular item and return back the nodes associated with it. I have searched the web to no abounds and was wondering if someone would mind letting me know what I am missing.

Here is my XML:

<?xml version="1.0" encoding="utf-8"?>
  <ServiceName ID="AddNote">
     <Client ID="Opera">
<ServiceName ID="AuthenticateUser">
     <Client ID="Gas Station">

Here is my code... I have a single text box named txtMethod and radio buttons that are selected to help search a node associated with it. Here is what I have...

Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
        Dim ClientRdo As String
        'Radio Button Check on Search
        If rdoOpera.Checked = True Then
            ClientRdo = "Opera"
        ElseIf rdoGasStation.Checked = True Then
            ClientRdo = "Gas Station"
            MsgBox("You must choose a client to search the file.")
        End If

        Dim xmldoc As New System.Xml.XmlDocument()
        Dim xmlnode As System.Xml.XmlNodeList
        Dim i As Integer
        Dim fs As New System.Xml.XmlTextReader("C:\MyFile.xml")
        xmlnode = xmldoc.GetElementsByTagName("Client")
'This is the text box that I want to search for "AddNote" or Service ID in the XML
Dim Method As String
        Method = txtMethod.Text

        Do Until fs.EOF
'This should find "AddNote" if it is entered into textbox
            xmldoc.SelectSingleNode("//ServiceConfiguration[ServiceName ID='" + Method + "']")
            'This should find either "Opera" or "Gas Station" along with the Service Name ID
            ClientRdo = xmlnode(i).ParentNode.Item(1).InnerText.Trim()
'It will continue to do this till it is found in the XML file

'Once found, it will display the results of the children in the remaining textboxes
        txtService2.Text = xmlnode(i).ChildNodes.Item(0).InnerText.Trim()
        txtMethod2.Text = xmlnode(i).ChildNodes.Item(1).InnerText.Trim()
        txtVersion.Text = xmlnode(i).ChildNodes.Item(2).InnerText.Trim()
        txtQue.Text = xmlnode(i).ChildNodes.Item(4).InnerText.Trim()

Any help would be greatly appreciated!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.