
Adding Nodes to TreeView and XML files
All you should have to do is write a recursive loop to do it, passing in the
first node in your xml document and the current node to add the child to in
the treeview...pseudo code follows:
Private Sub AttachNode(ByVal XMLNode As XmlElement, ByVal ParentNode As
TreeNode)
Dim TempNode As TreeNode =
ParentNode.Nodes.Add(XMLNode.Attributes.Item(0).NodeValue)
Dim i As Byte
For i = 0 To XMLNode.ChildNodes.Length - 1
AttachNode(XMLNode.ChildNodes.Item(i), TempNode)
Next
End Sub
Just call it after your XML is loaded and pass it the first node in the
document and the first node in the treeview to start it off
Hope this helps
Erik Porter
Microsoft .NET MVP
Quote:
> Can any one give me an example of adding Nodes to a treeview and adding
> child nodes?
> Also, how would I get the parent node for an app.config file?
> For example:
> <appsettings>
> <add key="Name" value="Seth" />
> <UselessInfo>
> <add key="Blah" value="Blahblah" />
> </UselessInfo>
> </appsetting
> I want to be able to see that the parent node for key 'Blah' is
> <UselessInfo>, and <UselessInfo>'s parent is <appsettings>.
> Thanks,
> Seth