TreeView
Actor
Type
Movie Title =
<?xml version="1.0"?> -<BLURays> -<Movie Title="Fallen"> <Actor>Denzel Washington</Actor> <Type>Thriller</Type> </Movie> -<Movie Title="Mad Max"> <Actor>Mel Gibson</Actor> <Type>Sci-Fi</Type> </Movie> -<Movie Title="Event Horizon"> <Actor>Sam Neill</Actor> <Type>Sci-Fi Horror</Type> </Movie> -<Movie Title="Happy Gilmore"> <Actor>Adam Sandler</Actor> <Type>Comedy</Type> </Movie> -<Movie Title="The Postman"> <Actor>Kevin Costner</Actor> <Type>Adventure</Type> </Movie> </BLURays>
Private Sub Prova2ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles Prova2ToolStripMenuItem.Click OpenFileDialog1.Multiselect = False OpenFileDialog1.ShowDialog() Dim fileName As String = Path.GetFileName(OpenFileDialog1.FileName) Dim filePath As String = OpenFileDialog1.FileName Me.Text = filePath Dim xmldoc As New XmlDataDocument() Dim xmlnode As XmlNode Dim fs As New FileStream(filePath, FileMode.Open, FileAccess.Read) xmldoc.Load(fs) xmlnode = xmldoc.ChildNodes(1) TreeView1.Nodes.Clear() TreeView1.Nodes.Add(New TreeNode(xmldoc.DocumentElement.Name)) Dim tNode As TreeNode tNode = TreeView1.Nodes(0) AddNode(xmlnode, tNode) End Sub Private Sub AddNode(ByVal inXmlNode As XmlNode, ByVal inTreeNode As TreeNode) Dim xNode As XmlNode Dim tNode As TreeNode Dim nodeList As XmlNodeList Dim i As Integer If inXmlNode.HasChildNodes Then nodeList = inXmlNode.ChildNodes For i = 0 To nodeList.Count - 1 xNode = inXmlNode.ChildNodes(i) inTreeNode.Nodes.Add(New TreeNode("Node: " + xNode.Name)) tNode = inTreeNode.Nodes(i) AddNode(xNode, tNode) Next Else inTreeNode.Text = inXmlNode.InnerText.ToString End If End Sub
treeView.Nodes[0].Nodes.Add(yourChildNode);
Nodes[0]
yourChildNode
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)