Link to home
Start Free TrialLog in
Avatar of Ruttensoft
Ruttensoft

asked on

Reading XML Values...

I have a question reading XML-Files. I am writing it in this format:

 <?xml version="1.0" ?>
- <!-- Template for Media Remote 2007
  -->
- <MediaRemote2007>
- <Settings>
  <Name>Test</Name>
  <Author>Sven Rutten</Author>
  <BackgroundImage />
- <Button1>
  <Text>Button1</Text>
  <BackColor>-1316371</BackColor>
  <ForeColor>-16777216</ForeColor>
  <Left>78</Left>
  <Top>119</Top>
  <Width>75</Width>
  <Height>23</Height>
  <Command>Nothing</Command>
  </Button1>
- <Button2>
  <Text>Button2</Text>
  <BackColor>-65281</BackColor>
  <ForeColor>-16711936</ForeColor>
  <Left>11</Left>
  <Top>170</Top>
  <Width>93</Width>
  <Height>26</Height>
  <Command>Nothing</Command>
  </Button2>
- <pb1>
  <Left>16</Left>
  <Top>25</Top>
  <Width>64</Width>
  <Height>48</Height>
  <Command>Nothing</Command>
  <Picture />
  </pb1>
- <pb2>
  <Left>80</Left>
  <Top>0</Top>
  <Width>56</Width>
  <Height>40</Height>
  <Command />
  <Picture />
  </pb2>
  </Settings>
  </MediaRemote2007>

I have several Buttons and Picturebox. How can I now loop through all these buttons and picturebox and read the values of them?

Thanks

Sven
ASKER CERTIFIED SOLUTION
Avatar of Darren
Darren
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you don't need the save

take out the line

NewXmlDoc2.Save("C:\test\test.xml")
This line should also be...

oNodeList = oRootNode.SelectNodes("/MediaRemote2007/Settings/Button")
Here is how you get the Text contents:

For Each oNode In oNodeList
 MessageBox.Show(oNode.Item("Text").InnerText.ToString)
 ' You can loop through each button or picture box node and pull out the values
Next

Hope all of this helps,

Darren
Avatar of Ruttensoft
Ruttensoft

ASKER

Thanks