Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Newbie to XML.

From: Anand Kasotia <akasotia@--------.--->
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 ***


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent