From: Steffen Leppert on
Hello!

Is there anybody here who has created a treewalker class for the MSXML2
library in VB6?

I have a Java project here which uses Xerces for XML handling.
In this code I see that a treewalker is used to iterate through the
nodes, but I am afraid that I don't really understand it yet. I cannot
run the Java code, so I have to re-write this code without being able to
check if I can produce the same results.

If somebody already did something like that, can he please tell me?

Have a nice day!
Steffen Leppert
From: Paul Clement on
On Tue, 27 Jul 2010 18:04:39 +0200, Steffen Leppert <st.leppert(a)gmx.de> wrote:

� Hello!

� Is there anybody here who has created a treewalker class for the MSXML2
� library in VB6?

� I have a Java project here which uses Xerces for XML handling.
� In this code I see that a treewalker is used to iterate through the
� nodes, but I am afraid that I don't really understand it yet. I cannot
� run the Java code, so I have to re-write this code without being able to
� check if I can produce the same results.

� If somebody already did something like that, can he please tell me?

� Have a nice day!
� Steffen Leppert

How about the following...

http://www.vbrad.com/article.aspx?id=76


Paul
~~~~
Microsoft MVP (Visual Basic)
From: Steffen Leppert on
Okay, looks good, thanks, but an intermediate question, please...
I think the code below is relatively easy to read.
Do you have any idea what I'm doing wrong?
Some nodes are not debug.print'ed.
In the code you gave me, they ARE shown.
I guess I am missing something obvious here...

Private sub pStart

Dim Doc As MSXML2.DOMDocument60
Set Doc = New MSXML2.DOMDocument60
Doc.async = False
Call Doc.Load("C:\myfile.xml")

Dim first As MSXML2.IXMLDOMElement
Set first = Doc.documentElement.firstChild

Call pList(first, "")

End Sub

Private Sub pList(ByVal uNode As MSXML2.IXMLDOMNode, ByVal uTab As String)

DoEvents

If Not uNode.hasChildNodes Then
Exit Sub
End If

Dim child As MSXML2.IXMLDOMNode

For Each child In uNode.childNodes

Debug.Print uTab & "Node Name: " & uNode.nodeName & ", Value: "
& uNode.nodeValue

Dim a As MSXML2.IXMLDOMAttribute
For Each a In uNode.Attributes
Debug.Print uTab & "Attribute Name: " & a.Name & ", Value:
" & a.Value
Next a

If child.hasChildNodes Then
'call recursively
pList child, uTab & vbTab
End If

Next child

End Sub
From: Steffen Leppert on
Resolved:

I made a typing error.