I am trying to build a menu in .net using a treeview control populated by an XML file. This XML is divided into several sections since the same xml is used throughout the application. It is indexed by Area, Application, and Page. I need a way to filter the treeview to only display nodes that are specific to the page I am currently on. I am new to .net and do not know the syntax for doing this. My code currently displays everything in the xml file. Any advice on this is appreciated. Thanks,
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim dom As New XmlDocument()
dom.Load(TextBox1.Text)
TreeView1.Nodes.Clear()
TreeView1.Nodes.Add(New TreeNode(dom.DocumentElement.Name))
Dim tNode As New TreeNode()
tNode = TreeView1.Nodes(0)
AddNode(dom.DocumentElement, tNode)
TreeView1.ExpandAll()
Catch xmlEx As XmlException
MessageBox.Show(xmlEx.Message)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub AddNode(ByRef inXmlNode As XmlNode, ByRef inTreeNode As TreeNode)
Dim xNode As XmlNode
Dim tNode As TreeNode
Dim Parent As XmlNode
Dim nodeList As XmlNodeList
Dim i As Long
If inXmlNode.HasChildNodes() Then
nodeList = inXmlNode.ChildNodes
For i = 0 To nodeList.Count - 1
xNode = inXmlNode.ChildNodes(i)
inTreeNode.Nodes.Add(New TreeNode(xNode.Name))
tNode = inTreeNode.Nodes(i)
AddNode(xNode, tNode)
Next
Else
inTreeNode.Text = (inXmlNode.OuterXml).Trim
End If
End Sub