People who looked at this will buy:
The first approach is correct. A bare bones implementation:
Dim oFS : Set oFS = CreateObject("Scripting.FileSystemObject")
Dim sFSpec : sFSpec = oFS.GetAbsolutePathName("..\data\so15218800.xml")
Dim oXML : Set oXML = CreateObject("Msxml2.DOMDocument.6.0")
oXML.load sFSpec
If 0 = oXML.parseError Then
recursiveTraversalAtt oXML.documentElement, 0
Else
WScript.Echo objMSXML.parseError.reason
End If
Sub recursiveTraversalAtt(oElm, nIndent)
WScript.Echo Space(nIndent), oElm.tagName
If 0 < oElm.childNodes.length Then
If 0 < oElm.attributes.length Then showAttr oElm, nIndent
Dim oChild
For Each oChild In oElm.childNodes
recursiveTraversalAtt oChild, nIndent + 2
Next
Else
If 0 < oElm.attributes.length Then showAttr oElm, nIndent
End If
End Sub
Sub showAttr(oElm, nIndent)
Dim oAttr
For Each oAttr In oElm.attributes
WScript.Echo Space(nIndent + 1), oAttr.name, oAttr.value
Next
End Sub
output:
TestSuites
TestSuite
SuiteName Regression
TCName TestCase 1
TestCase
TCName TestCase 1
abc 123
TestStep
TSName TestStep 1
TestStep
TSName TestStep 2
NoAttr
TestSuite
SuiteName Regression
TCName TestCase 1
TestStep
TSName TestStep 1
TestCase
TCName TestCase 2
TestStep
TSName TestStep 1
TestStep
TSName TestStep 2
TestSuite
TestSuite
SuiteName Sanity