Dim stringtest
Function Getxmltest (ByVal xmlFilePath, ByVal nodeName)
Dim xmlDoc, xmlRoot
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = False
xmlDoc.Load(xmlFilePath)
If xmlDoc.parseError.errorCode <> 0 Then
MsgBox "xml格式不对,原因是:" &Chr(13)&Chr(10) & xmlDoc.parseError.reason
Exit Function
End If
Set xmlRoot = xmlDoc.documentElement
MsgBox xmlRoot.nodeName
xmlRecursion xmlRoot, nodeName
End Function
Function xmlRecursion (Byref xmlRoot,Byref nodeNameOne)
MsgBox xmlRoot.nodeName
If xmlRoot.nodeName = nodeNameOne and xmlRoot.hasChildNodes Then
If xmlRoot.childNodes.item(0).nodeName = "#cdata-section" Then
stringtest = stringtest & xmlRoot.nodeName & ":" & xmlRoot.childNodes.item(0).nodeValue &Chr(13)&Chr(10)
End If
End If
If xmlRoot.hasChildNodes Then
For Each childNodeItem In xmlRoot.ChildNodes
If childNodeItem.hasChildNodes Then
xmlRecursion childNodeItem,nodeNameOne
End If
Next
End If
End Function
Getxmltest "C:\Program Files\Mercury Interactive\QuickTest Professional\Tests\Test3\Res1\Report\Results.xml","Summary"
MsgBox stringtest