Results 1 to 4 of 4

Thread: [RESOLVED] [Question]Xml attributes into TextBox

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2013
    Posts
    4

    Resolved [RESOLVED] [Question]Xml attributes into TextBox

    Hi there,

    So here's my xml file. I would like to do is to get all the Tab value into my textbox using a button to do so.

    Code:
    <?xml version="1.0" standalone="yes"?>
    <programsetting>
      <Main>
        <Test Tab="1" />
        <Test Tab="2" />
        <Test Tab="3" />
        <Test Tab="4" />
      </Main>
    </programsetting>
    Here's my button code but was able to get the 1st tab value = "1" though.

    Code:
    doc.Load("Copy of GUI_Setting.xml")
            Dim node As XmlNode = doc.SelectSingleNode("/programsetting/Main/Test")
            Dim att = node.Attributes("Tab")
            For Each whatever In att
                TextBox2.Text = att.Value
            Next
    Thank you.

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: [Question]Xml attributes into TextBox

    I haven't tried running it but something like this should work
    Code:
    doc.Load("Copy of GUI_Setting.xml")
            Dim node As XmlNode
            Dim nodeList As XmlNodeList = doc.SelectNodes("/programsetting/Main/Test")
            Dim att = XmlAttribute
            
           For Each node In nodeList 
                att = node.Attributes("Tab")
                TextBox2.Text = TextBox2.Text & att.Value & vbCrLf
            Next
    Last edited by MarkT; Jun 19th, 2013 at 12:59 PM.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2013
    Posts
    4

    Re: [Question]Xml attributes into TextBox

    Quote Originally Posted by MarkT View Post
    I haven't tried running it but something like this should work
    Code:
    doc.Load("Copy of GUI_Setting.xml")
            Dim node As XmlNode
            Dim nodeList As XmlNodeList = doc.SelectNodes("/programsetting/Main/Test")
            Dim att = XmlAttribute
            
           For Each node In nodeList 
                att = node.Attributes("Tab")
                TextBox2.Text = TextBox2.Text & att.Value & vbCrLf
            Next
    Thanks for the reply.
    It ain't able to work. And give out an error "Object reference not set to an instance of an object." @ TextBox2.Text = TextBox2.Text & att.Value & vbCrLf
    Oh and by the way, DIm att = XmlAttribute need to be Dim att As XmlAttribute

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2013
    Posts
    4

    Re: [RESOLVED] [Question]Xml attributes into TextBox

    Nvm. I found a solution already. THANKS!!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width