Read XML File using

Posted on 2007-07-24
Last Modified: 2013-11-26
I needed to read the contents of a XML file.  Below is a the contents of the file:

<?xml version="1.0"?>
<!--Test file for database settings-->
  <DB_Name />
  <DB_Login />
  <DB_Password />
  <DB_Table />

What would be a quick way to read each of the values in this file?  I am using
Question by:Mike_Stevens
    LVL 46

    Expert Comment

    by:Wayne Taylor (webtubbs)
    Hello Mike_Stevens,

    Try this....

            Dim xmlDoc As New Xml.XmlDocument
            For Each nd As Xml.XmlNode In xmlDoc.DocumentElement
                MsgBox(nd.Name & " = " & nd.InnerText)



    Author Comment

    I need to be able to read each node and then assign the value to a textbox...


    Me.textbox1.text = "the value of DB_Type node"
    Me.textbox1.text = "the value of DB_Security node"
    LVL 46

    Accepted Solution

           Dim xmlDoc As New Xml.XmlDocument
            TextBox1.Text = xmlDoc.DocumentElement.SelectSingleNode("DB_Type").InnerText
            TextBox2.Text = xmlDoc.DocumentElement.SelectSingleNode("DB_Security").InnerText
            TextBox3.Text = xmlDoc.DocumentElement.SelectSingleNode("DB_Name").InnerText
            TextBox4.Text = xmlDoc.DocumentElement.SelectSingleNode("DB_Login").InnerText
            TextBox5.Text = xmlDoc.DocumentElement.SelectSingleNode("DB_Password").InnerText
            TextBox6.Text = xmlDoc.DocumentElement.SelectSingleNode("DB_Table").InnerText
            TextBox7.Text = xmlDoc.DocumentElement.SelectSingleNode("DB_Connection_TO").InnerText


    Author Comment

    by:Mike_Stevens are the best!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 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

    18 Experts available now in Live!

    Get 1:1 Help Now