Hi to everyone, just want to ask the the write code for my problem...
i have a xml file, i load it in treeview
but all i can see is one of its attribute, i wanted also to see the
element name and its attribute if theres any...


Dim document As New System.Xml.XmlDataDocument()

        document.Load("C:\Documents and Settings\DFS\Desktop\OKEY Files
\PDFTable.xml")
        populateTreeControl(document.DocumentElement, tv1.Nodes)


Public Sub populateTreeControl( _
      ByVal document As System.Xml.XmlNode, ByVal nodes As
System.Windows.Forms.TreeNodeCollection)

        Dim node As System.Xml.XmlNode
        For Each node In document.ChildNodes
            ' If the element has a value, display it;
            ' otherwise display the first attribute
            ' (if there is one) or the element name
            ' (if there isn't)
            Dim [text] As String
            Dim [text1] As String
            Dim [text2] As String
            'If node.Value <> Nothing Then
            [text] = node.Value
            'Else
            'If Not node.Attributes Is Nothing And
node.Attributes.Count > 0 Then
            [text] = node.Attributes(0).Value
            'Else
            [text1] = node.Name
            [text2] = node.Name
            'End If
            'End If

            Dim new_child As New TreeNode([text])
            'Dim new_child1 As New TreeNode([text1])
            nodes.Add(new_child)
            'nodes.Add(new_child1)
            populateTreeControl(node, new_child.Nodes)
            'populateTreeControl(node, new_child1.Nodes)
        Next node
    End Sub

Reply via email to