#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    194
    Rep Power
    329

    Read simple xml file


    Let's say I have a very simple xml file, something like:
    Code:
    <root>
      <ProjectName>Some project</ProjectName>
      <Date>2010, Nov 14</Date>
      <ProjectAddress>Here and there</ProjectAddress>
      <CompanyName>Acme Ltd</CompanyName>
    </root>
    Nodes are always the same, only the value will change. How do I read the value of the node, e.g. into a textbox? I'm using VB10 to write this file.
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,068
    Rep Power
    9398
    You mean VB.NET?

    There's a KB for that.

    Protip: Next time try Google. That's what I just did.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    194
    Rep Power
    329
    VB.NET indeed... I of course tried to search a solution, but all I found was a bit overkill for such a simple task. I scribbled this, which actually works OK for my purposes.
    Code:
    Dim doc As XmlDocument = New XmlDocument
    doc.Load(folderDlg.SelectedPath & "\" & "settings.xml")
    Dim roots As XmlElement = doc.DocumentElement
    ' and then populate textboxes...
    txtProjectName.Text = roots.SelectSingleNode("/root/ProjectName").InnerText
    ' and so on...

IMN logo majestic logo threadwatch logo seochat tools logo