Wilburt Leftlong
2004-05-25 18:42:29 UTC
I'm adding an XML node values to a tree like so:
Private Sub bttnLoad_Click()
On Error GoTo myErr
Dim xmlDoc As DOMDocument30
Set xmlDoc = New DOMDocument30
xmlDoc.async = False
If Not xmlDoc.Load("C:\XMLNodes.xml") Then
MsgBox "Could not load file"
Exit Sub
End If
TreeView1.Nodes.Clear
Dim iNode As Integer
Dim newElement As IXMLDOMElement
For iNode = 0 To xmlDoc.getElementsByTagName("NODE").length - 1
Set newElement = xmlDoc.getElementsByTagName("NODE").Item(iNode)
'if no parent key, it must be a root element
If newElement.getAttribute("ParentKey") = "" Then
TreeView1.Nodes.Add , , newElement.getAttribute("Key"),
newElement.getAttribute("Tag")
Else
TreeView1.Nodes.Add newElement.getAttribute("ParentKey"),
tvwChild, newElement.getAttribute("Key"), newElement.getAttribute("Caption")
End If
Next
myErr:
If Err.Number > 0 Then
MsgBox Err.Description
End If
End Sub
With an XML file that looks like this:
<NODES>
<NODE Caption="fdf445df6" Key="K7055473" Tag="sdfds" ParentKey=""/>
<NODE Caption="sfdf3222" Key="K7055474" Tag="sdsdf" ParentKey=""/>
<NODE Caption="ffd3434" Key="K7055475" Tag="sfds" ParentKey="K7055474"/>
<NODE Caption="asdasdasd" Key="K7055476" Tag="sdds" ParentKey="K7055473"/>
</NODES>
And attempting to display the current node in a textbox like so:
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
nodeValue.Text = TreeView1.SelectedItem.Tag
End Sub
I am unable to access the value of attribute "Tag" for some reason though.
I can however dislay the value of "Key", and others.
Am I loading my XML file into my tree incorrectly?
Thanks
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.690 / Virus Database: 451 - Release Date: 5/22/2004
Private Sub bttnLoad_Click()
On Error GoTo myErr
Dim xmlDoc As DOMDocument30
Set xmlDoc = New DOMDocument30
xmlDoc.async = False
If Not xmlDoc.Load("C:\XMLNodes.xml") Then
MsgBox "Could not load file"
Exit Sub
End If
TreeView1.Nodes.Clear
Dim iNode As Integer
Dim newElement As IXMLDOMElement
For iNode = 0 To xmlDoc.getElementsByTagName("NODE").length - 1
Set newElement = xmlDoc.getElementsByTagName("NODE").Item(iNode)
'if no parent key, it must be a root element
If newElement.getAttribute("ParentKey") = "" Then
TreeView1.Nodes.Add , , newElement.getAttribute("Key"),
newElement.getAttribute("Tag")
Else
TreeView1.Nodes.Add newElement.getAttribute("ParentKey"),
tvwChild, newElement.getAttribute("Key"), newElement.getAttribute("Caption")
End If
Next
myErr:
If Err.Number > 0 Then
MsgBox Err.Description
End If
End Sub
With an XML file that looks like this:
<NODES>
<NODE Caption="fdf445df6" Key="K7055473" Tag="sdfds" ParentKey=""/>
<NODE Caption="sfdf3222" Key="K7055474" Tag="sdsdf" ParentKey=""/>
<NODE Caption="ffd3434" Key="K7055475" Tag="sfds" ParentKey="K7055474"/>
<NODE Caption="asdasdasd" Key="K7055476" Tag="sdds" ParentKey="K7055473"/>
</NODES>
And attempting to display the current node in a textbox like so:
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
nodeValue.Text = TreeView1.SelectedItem.Tag
End Sub
I am unable to access the value of attribute "Tag" for some reason though.
I can however dislay the value of "Key", and others.
Am I loading my XML file into my tree incorrectly?
Thanks
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.690 / Virus Database: 451 - Release Date: 5/22/2004