• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 377
  • Last Modified:

Populate a TextBox via XML?

Hi,

I'm busy setting up an application I made to get details from an XML file and import the details into parts of my application. At present i've managed to populate List and Combo boxes using the below code, however can anyone show me how to import details into a TextBox?

This is the code i'm using to populate List and Combo Boxes with the details in the <test> tags within my XML file.

        Dim node1 As Xml.XmlNode = xmlDoc.SelectSingleNode("//test")
        If node1 IsNot Nothing Then
            For x As Integer = 0 To node1.ChildNodes.Count - 1
                Me.ComboBox1.Items.Add(node1.ChildNodes.Item(x).InnerText.ToString)
            Next
        End If

For the text box, it's called TextBox1 and the details I want to put in the text box are contained in the <text> tags in my XML file as shown below.

Assistant.xml

<?xml version="1.0" encoding="UTF-8"?>
 
<Records>
 
<TextBox>
<text>Description 1</text>
</TextBox>

</Records>


Many thanks,

Paul.
0
m0tSiE
Asked:
m0tSiE
1 Solution
 
jpaulinoCommented:
Hi Paul,
You can do this way:

        Dim xmlDoc As New Xml.XmlDocument
        xmlDoc.Load("c:\myXml.xml")
 
        Dim node1 As Xml.XmlNode = xmlDoc.SelectSingleNode("//TextBox/text")
        If node1 IsNot Nothing Then
            Me.TextBox1.Text = node1.ChildNodes.Item(0).InnerText.ToString
        End If

Open in new window

0
 
m0tSiEAuthor Commented:
Cheers.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now