title: How to populate a treeview from a XML file with multiple child nodes?
body: <p>I´m trying to populate a TreeView component in VB.NET from a XML file. It´s a large XML file and I chopped it up in order to give you guys an idea about how it is structured. I´m new to VB.NET so I´m having a hard time to figure this out. Below there´s an image of the order I expect this data to be shown in the TreeView, and I added some arrows so you can understand where the data is supposed to come from in the XML structure.</p>
  
  <p>I found and tried to adapt a code I got from a Microsoft tutorial, but it´s based on a much simpler XML structure and it´s not working with my file.</p>
  
  <p>The arrows in the image are being shown out of synch with the XML tags &amp; nodes but my goal was to avoid the arrows and rectangles overlaping each other making the picture unreadable.</p>
  
  <p>When we have a node named "Cutter" it´s a different type of component, and more than one may be comprised within the current "Cutter" or "Holder" node, so they are separated by the "Reference" tag. If it´s named "Holder" it´s another component type on the tool stackup... Every new tool starts with an element named "Tool". </p>
  
  <p>Below the picture what I´m trying to do in the code:</p>
  
  <p><a href="http://www.screencast.com/t/ucr4Z4a77L7" rel="nofollow">Tree View Explanation</a></p>
  
  <pre><code>Private Sub btnSearchTLS_Click(sender As Object, e As EventArgs) Handles btnSearchTLS.Click
  
          Try
              ' SECTION 1. Create a DOM Document and load the XML data into it.
              Dim dom As New XmlDocument()
              dom.Load(txtFileOpenTLS_2.Text)
  
              ' SECTION 2. Initialize the treeview control.
              tviewToolIDs.Nodes.Clear()
              tviewToolIDs.Nodes.Add(New TreeNode(dom.DocumentElement.Name))
              Dim tNode As New TreeNode()
              tNode = tviewToolIDs.Nodes(0)
  
              ' SECTION 3. Populate the TreeView with the DOM nodes.
              AddNode(dom.DocumentElement, tNode)
              tviewToolIDs.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 nodeList As XmlNodeList
          Dim i As Integer
  
          ' Loop through the XML nodes until the leaf is reached.
          ' Add the nodes to the TreeView during the looping process.
          If inXmlNode.HasChildNodes() Then
              nodeList = inXmlNode.ChildNodes
              For i = 0 To nodeList.Count - 1
                  xNode = inXmlNode.(i)
                  inTreeNode.Nodes.Add(New TreeNode(xNode.Name))
                  tNode = inTreeNode.Nodes(i)
                  AddNode(xNode, tNode)
              Next
          Else
              ' Here you need to pull the data from the XmlNode based on the
              ' type of node, whether attribute values are required, and so forth.
              inTreeNode.Text = (inXmlNode.OuterXml).Trim
          End If
      End Sub
  </code></pre>
  
  <p>Here´s the XML file:</p>
  
  <pre><code>    &lt;?xml version="1.0"?&gt;
  &lt;ToolLibrary Version="7.3"&gt;
      &lt;Tools&gt;
      &lt;Tool ID="100004" Units="Millimeter"&gt;
        &lt;Description&gt;100004&lt;/Description&gt;
        &lt;Teeth&gt;1&lt;/Teeth&gt;
        &lt;Type&gt;Turning&lt;/Type&gt;
        &lt;Cutter&gt;
          &lt;Reference ID="12140 - N123G2-0318-0008"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Torneamento - Insertos paramétricos&lt;/ToolID&gt;
            &lt;EntityName&gt;12140 - N123G2-0318-0008&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;34.2&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-82.3&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;Rotation&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;-90&lt;/Y&gt;
              &lt;Z&gt;0&lt;/Z&gt;
            &lt;/Rotation&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
        &lt;/Cutter&gt;
        &lt;Holder&gt;
          &lt;Reference ID="12135 - C5-570-32-LF"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Holders &amp;amp; Acessorios&lt;/ToolID&gt;
            &lt;EntityName&gt;12135 - C5-570-32-LF&lt;/EntityName&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="12139 - 570-32L123G18B130A"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Holders &amp;amp; Acessorios&lt;/ToolID&gt;
            &lt;EntityName&gt;12139 - 570-32L123G18B130A&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;21&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-42&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
        &lt;/Holder&gt;
        &lt;DrivenPoint ID="1"&gt;
          &lt;Type&gt;-1&lt;/Type&gt;
          &lt;Radius&gt;0&lt;/Radius&gt;
          &lt;X&gt;35&lt;/X&gt;
          &lt;Y&gt;0&lt;/Y&gt;
          &lt;Z&gt;-83.1&lt;/Z&gt;
        &lt;/DrivenPoint&gt;
        &lt;DrivenPoint ID="2"&gt;
          &lt;Type&gt;-1&lt;/Type&gt;
          &lt;Radius&gt;0&lt;/Radius&gt;
          &lt;X&gt;31.82&lt;/X&gt;
          &lt;Y&gt;0&lt;/Y&gt;
          &lt;Z&gt;-83.1&lt;/Z&gt;
        &lt;/DrivenPoint&gt;
        &lt;CutterCompensation ID="1"&gt;0.8&lt;/CutterCompensation&gt;
        &lt;CutterCompensation ID="2"&gt;0.8&lt;/CutterCompensation&gt;
      &lt;/Tool&gt;
      &lt;Tool ID="100171" Units="Millimeter"&gt;
        &lt;Description&gt;100171&lt;/Description&gt;
        &lt;Teeth&gt;1&lt;/Teeth&gt;
        &lt;Type&gt;Turning&lt;/Type&gt;
        &lt;Cutter&gt;
          &lt;Reference ID="12349 - CNMG120412"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Torneamento - Insertos paramétricos&lt;/ToolID&gt;
            &lt;EntityName&gt;12349 - CNMG120412&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;-35.8&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-291.8&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;Rotation&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;-5&lt;/Y&gt;
              &lt;Z&gt;0&lt;/Z&gt;
            &lt;/Rotation&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
        &lt;/Cutter&gt;
        &lt;Holder&gt;
          &lt;Reference ID="11977 - C6-390.410-100-110A"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Holders &amp;amp; Acessorios&lt;/ToolID&gt;
            &lt;EntityName&gt;11977 - C6-390.410-100-110A&lt;/EntityName&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="11978 - C6-570-2C-60-148-40L"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Holders &amp;amp; Acessorios&lt;/ToolID&gt;
            &lt;EntityName&gt;11978 - C6-570-2C-60-148-40L&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-110&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="11979 - SL-PCLNL-40-12HP"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Holders &amp;amp; Acessorios&lt;/ToolID&gt;
            &lt;EntityName&gt;11979 - SL-PCLNL-40-12HP&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;-10&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-258&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
        &lt;/Holder&gt;
        &lt;DrivenPoint ID="1"&gt;
          &lt;Type&gt;-1&lt;/Type&gt;
          &lt;Radius&gt;0&lt;/Radius&gt;
          &lt;X&gt;-37&lt;/X&gt;
          &lt;Y&gt;0&lt;/Y&gt;
          &lt;Z&gt;-293&lt;/Z&gt;
        &lt;/DrivenPoint&gt;
        &lt;DrivenPoint ID="2"&gt;
          &lt;Type&gt;-1&lt;/Type&gt;
          &lt;Radius&gt;0&lt;/Radius&gt;
          &lt;X&gt;-37&lt;/X&gt;
          &lt;Y&gt;0&lt;/Y&gt;
          &lt;Z&gt;-293&lt;/Z&gt;
        &lt;/DrivenPoint&gt;
        &lt;CutterCompensation ID="1"&gt;1.2&lt;/CutterCompensation&gt;
        &lt;CutterCompensation ID="2"&gt;1.2&lt;/CutterCompensation&gt;
      &lt;/Tool&gt;
      &lt;Tool ID="100178" Units="Millimeter"&gt;
        &lt;Description&gt;100178&lt;/Description&gt;
        &lt;Teeth&gt;8&lt;/Teeth&gt;
        &lt;Type&gt;Milling&lt;/Type&gt;
        &lt;Cutter&gt;
          &lt;Reference ID="10084 - R90MT-12-05-RM"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Rotativas - Insertos Paramétricos&lt;/ToolID&gt;
            &lt;EntityName&gt;10084 - R90MT-12-05-RM&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;44&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-614&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="10084 - R90MT-12-05-RM1"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Rotativas - Insertos Paramétricos&lt;/ToolID&gt;
            &lt;EntityName&gt;10084 - R90MT-12-05-RM&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;31.112698&lt;/X&gt;
              &lt;Y&gt;-31.112698&lt;/Y&gt;
              &lt;Z&gt;-614&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;Rotation&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-45&lt;/Z&gt;
            &lt;/Rotation&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="10084 - R90MT-12-05-RM11"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Rotativas - Insertos Paramétricos&lt;/ToolID&gt;
            &lt;EntityName&gt;10084 - R90MT-12-05-RM&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;31.112698&lt;/X&gt;
              &lt;Y&gt;31.112698&lt;/Y&gt;
              &lt;Z&gt;-614&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;Rotation&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;45&lt;/Z&gt;
            &lt;/Rotation&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="10084 - R90MT-12-05-RM12"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Rotativas - Insertos Paramétricos&lt;/ToolID&gt;
            &lt;EntityName&gt;10084 - R90MT-12-05-RM&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;-44&lt;/Y&gt;
              &lt;Z&gt;-614&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;Rotation&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-90&lt;/Z&gt;
            &lt;/Rotation&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="10084 - R90MT-12-05-RM13"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Rotativas - Insertos Paramétricos&lt;/ToolID&gt;
            &lt;EntityName&gt;10084 - R90MT-12-05-RM&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;44&lt;/Y&gt;
              &lt;Z&gt;-614&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;Rotation&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;90&lt;/Z&gt;
            &lt;/Rotation&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="10084 - R90MT-12-05-RM14"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Rotativas - Insertos Paramétricos&lt;/ToolID&gt;
            &lt;EntityName&gt;10084 - R90MT-12-05-RM&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;-31.112698&lt;/X&gt;
              &lt;Y&gt;31.112698&lt;/Y&gt;
              &lt;Z&gt;-614&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;Rotation&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;135&lt;/Z&gt;
            &lt;/Rotation&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="10084 - R90MT-12-05-RM15"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Rotativas - Insertos Paramétricos&lt;/ToolID&gt;
            &lt;EntityName&gt;10084 - R90MT-12-05-RM&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;-44&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-614&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;Rotation&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;180&lt;/Z&gt;
            &lt;/Rotation&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="10084 - R90MT-12-05-RM"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Rotativas - Insertos Paramétricos&lt;/ToolID&gt;
            &lt;EntityName&gt;10084 - R90MT-12-05-RM&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;-31.1127&lt;/X&gt;
              &lt;Y&gt;-31.1127&lt;/Y&gt;
              &lt;Z&gt;-614&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;Rotation&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-135&lt;/Z&gt;
            &lt;/Rotation&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
        &lt;/Cutter&gt;
        &lt;Holder&gt;
          &lt;Reference ID="11974 - C8-390.410-100 120A"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Holders &amp;amp; Acessorios&lt;/ToolID&gt;
            &lt;EntityName&gt;11974 - C8-390.410-100 120A&lt;/EntityName&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="12001 - C8-391.01-80 065"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Holders &amp;amp; Acessorios&lt;/ToolID&gt;
            &lt;EntityName&gt;12001 - C8-391.01-80 065&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-120&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="12001 - C8-391.01-80 065"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Holders &amp;amp; Acessorios&lt;/ToolID&gt;
            &lt;EntityName&gt;12001 - C8-391.01-80 065&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-185&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="12002 - C8-391.05-CD-32-320"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Holders &amp;amp; Acessorios&lt;/ToolID&gt;
            &lt;EntityName&gt;12002 - C8-391.05-CD-32-320&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-250&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="10707 - FCM-D100-32-11"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Holders &amp;amp; Acessorios&lt;/ToolID&gt;
            &lt;EntityName&gt;10707 - FCM-D100-32-11&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-570&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
        &lt;/Holder&gt;
        &lt;DrivenPoint ID="1"&gt;
          &lt;Type&gt;-1&lt;/Type&gt;
          &lt;Radius&gt;0&lt;/Radius&gt;
          &lt;X&gt;0&lt;/X&gt;
          &lt;Y&gt;0&lt;/Y&gt;
          &lt;Z&gt;-620&lt;/Z&gt;
        &lt;/DrivenPoint&gt;
        &lt;DrivenPoint ID="2"&gt;
          &lt;Type&gt;-1&lt;/Type&gt;
          &lt;Radius&gt;0&lt;/Radius&gt;
          &lt;X&gt;0&lt;/X&gt;
          &lt;Y&gt;0&lt;/Y&gt;
          &lt;Z&gt;-620&lt;/Z&gt;
        &lt;/DrivenPoint&gt;
        &lt;CutterCompensation ID="1"&gt;50&lt;/CutterCompensation&gt;
        &lt;CutterCompensation ID="2"&gt;50&lt;/CutterCompensation&gt;
      &lt;/Tool&gt;
      &lt;Tool ID="100192" Units="Millimeter"&gt;
        &lt;Description&gt;100192&lt;/Description&gt;
        &lt;Teeth&gt;1&lt;/Teeth&gt;
        &lt;Type&gt;Milling&lt;/Type&gt;
        &lt;Cutter&gt;
          &lt;Reference ID="10087 - 880-05-03-05H-C-GM"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Rotativas - Insertos Paramétricos&lt;/ToolID&gt;
            &lt;EntityName&gt;10087 - 880-05-03-05H-C-GM&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;-7.9&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-233.5&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;Rotation&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;180&lt;/Z&gt;
            &lt;/Rotation&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="10088 - 880-05 03 W05H-P-GM"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Rotativas - Insertos Paramétricos&lt;/ToolID&gt;
            &lt;EntityName&gt;10088 - 880-05 03 W05H-P-GM&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;12&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-233.5&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
        &lt;/Cutter&gt;
        &lt;Holder&gt;
          &lt;Reference ID="12007 - C4-390.410-100-090A"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Holders &amp;amp; Acessorios&lt;/ToolID&gt;
            &lt;EntityName&gt;12007 - C4-390.410-100-090A&lt;/EntityName&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="12033 - 880-D2500C4-04"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Holders &amp;amp; Acessorios&lt;/ToolID&gt;
            &lt;EntityName&gt;12033 - 880-D2500C4-04&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;0&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-90&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
        &lt;/Holder&gt;
        &lt;DrivenPoint ID="1"&gt;
          &lt;Type&gt;-1&lt;/Type&gt;
          &lt;Radius&gt;0&lt;/Radius&gt;
          &lt;X&gt;0&lt;/X&gt;
          &lt;Y&gt;0&lt;/Y&gt;
          &lt;Z&gt;-234&lt;/Z&gt;
        &lt;/DrivenPoint&gt;
      &lt;/Tool&gt;
      &lt;Tool ID="801154" Units="Millimeter"&gt;
        &lt;Description&gt;801154&lt;/Description&gt;
        &lt;Teeth&gt;1&lt;/Teeth&gt;
        &lt;Type&gt;Turning&lt;/Type&gt;
        &lt;Cutter&gt;
          &lt;Reference ID="11325 - MKI-176807-13_4.4"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Torneamento - Insertos 3D&lt;/ToolID&gt;
            &lt;EntityName&gt;11325 - MKI-176807-13_4.4&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;-5.18&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-225&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
        &lt;/Cutter&gt;
        &lt;Holder&gt;
          &lt;Reference ID="12016 - 392.410-100-ASHL-32"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Holders &amp;amp; Acessorios&lt;/ToolID&gt;
            &lt;EntityName&gt;12016 - 392.410-100-ASHL-32&lt;/EntityName&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
          &lt;Reference ID="11328 - MKS-366807-18"&gt;
            &lt;FileName&gt;TBT_MASTER_LIBRARY.tls&lt;/FileName&gt;
            &lt;ToolID&gt;Holders &amp;amp; Acessorios&lt;/ToolID&gt;
            &lt;EntityName&gt;11328 - MKS-366807-18&lt;/EntityName&gt;
            &lt;Origin&gt;
              &lt;X&gt;-8&lt;/X&gt;
              &lt;Y&gt;0&lt;/Y&gt;
              &lt;Z&gt;-55&lt;/Z&gt;
            &lt;/Origin&gt;
            &lt;NoSpin&gt;0&lt;/NoSpin&gt;
            &lt;Alternate&gt;Off&lt;/Alternate&gt;
          &lt;/Reference&gt;
        &lt;/Holder&gt;
        &lt;DrivenPoint ID="2"&gt;
          &lt;Type&gt;-1&lt;/Type&gt;
          &lt;Radius&gt;0&lt;/Radius&gt;
          &lt;X&gt;-2.980037&lt;/X&gt;
          &lt;Y&gt;0&lt;/Y&gt;
          &lt;Z&gt;-225&lt;/Z&gt;
        &lt;/DrivenPoint&gt;
        &lt;DrivenPoint ID="1"&gt;
          &lt;Type&gt;-1&lt;/Type&gt;
          &lt;Radius&gt;0&lt;/Radius&gt;
          &lt;X&gt;-7.380037&lt;/X&gt;
          &lt;Y&gt;0&lt;/Y&gt;
          &lt;Z&gt;-225&lt;/Z&gt;
        &lt;/DrivenPoint&gt;
        &lt;CutterCompensation ID="1"&gt;1.5&lt;/CutterCompensation&gt;
        &lt;CutterCompensation ID="2"&gt;1.5&lt;/CutterCompensation&gt;
      &lt;/Tool&gt;
    &lt;/Tools&gt;
   &lt;/ToolLibrary&gt;
  </code></pre>
  
  <p>What do I have to do in the code above (Considering it´s the right code - Feel free to come up with a new approach) to make my TreeView to be populated like shown in the image?</p>
  
  <p>I´m sorry for asking for a thing possibly already covered, I did a search and could not find something that could work with my XML example.</p>
  
  <p>Tks in advance,</p>
  
  <p>Daniel</p>