Populate a TextBox via XML?

Posted on 2009-02-22
Last Modified: 2012-05-06

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
        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.


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


Many thanks,

Question by:m0tSiE
    LVL 48

    Accepted Solution

    Hi Paul,
    You can do this way:

            Dim xmlDoc As New Xml.XmlDocument
            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


    Author Closing Comment


    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
    The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API ( has made its way into the popular lexicon of the English language.  A few years ago, …
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now