Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: Newbie to XML. Newbie to XML.To: NULL Date: 10/4/2006 2:33:00 PM
I am using XML DOM in VB6 to traverse through the XML file sequentially
(Top to Bottom) to grab all the tags.
Can someone expand on the code I have written below. My code only goes
two level deep in the XML "Tree structure". WITHOUT knowing how may
levels there are in the XML file, how can I traverse through and grab
all the tags.
I know selectNodes("//*") will accomplish this but want to know
programmatically how to read through the entire XML file and grabbing
all the XML tags without knowing how many level deep the XML files goes.
Private Sub Command2_Click()
Dim lFile_OutA As Long
Dim sTempVarA As String
Dim xmlDoc As New MSXML2.DOMDocument30
xmlDoc.async = False
xmlDoc.Load "C:\71991bw0000000Out.XML"
sTempVarA = sTempVarA & xmlDoc.nodeName & vbCrLf
Dim x As IXMLDOMElement
Set x = xmlDoc.documentElement
sTempVarA = sTempVarA & x.nodeName & vbCrLf
Dim y As IXMLDOMNodeList
Set y = x.childNodes
For i = 0 To y.length - 1
sTempVarA = sTempVarA & y(i).nodeName & vbCrLf
For z = 0 To y(i).childNodes.length - 1
If y(i).hasChildNodes = True And
y(i).childNodes(z).nodeType <> 3 Then
sTempVarA = sTempVarA & y(i).childNodes(z).nodeName
& vbCrLf
End If
Next
Next
lFile_OutA = FreeFile
Open "C:\output.txt" For Output As lFile_OutA
Print #lFile_OutA, sTempVarA
Close lFile_OutA
End Sub
Thanks.
*** Sent via Developersdex http://www.developersdex.com ***
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
