Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with XML documents and loops?
#4
What you refer to as child nodes are nothing more than a simple path just as in windows explorer if used right.
Now Brandonio forgot to mention the correct format of xml file to use.
In the folowing example i will show you what i consider to be the easiest Xml format and code snippet to use:

1. Xml Format:
Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<root>
    <ToolStipButtons>
        <item Name="btn1" url="www.google.com" />
        <item name="btn2" url="www.bing.com" />
    </ToolStripButtons>
    
</root>
2. Create the variable:
Just as Brandonio said create a new xml_doc variable and load your document
[code2=vbnet]Dim Xml_Doc As Xml.XmnDocument
Xml_Doc.load("path to xml file")[/code2]

3. Loop through nodes to create buttons:

[code2=vbnet]Dim node As Xml.XmlNode
For Each node In xml_doc.selectnodes("/root/ToolStrpButtons/item")'the path of the xml child node
Dim btn As New ToolStripButton _
With {.Name = node.Attributes("name").Value.ToString, _
.Tag = node.Attributes("url").Value.ToString}
AddHandler Button.Click, AddressOf TSButtonClick
Next[/code2]

Now add the same code for the handler as shown in brandonio's example and all should be fine.

If you have any errors or don't understand the coding above leave a reply and i'll be happy to help.
Sssssssssoftware developer...


Messages In This Thread
Help with XML documents and loops? - by Derek275 - 11-06-2012, 05:11 AM
Re: Help with XML documents and loops? - by Snake_eyes - 11-10-2012, 12:17 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)