|
请教大家:
在qtp生成的report.xml里面,summary这样定义的:
<!ELEMENT Summary (Param*)>
<!ATTLIST Summary sTime CDATA #IMPLIED eTime CDATA #IMPLIED passed CDATA #IMPLIED failed CDATA #IMPLIED warnings CDATA #IMPLIED retval CDATA #IMPLIED stopped (False|True) "False" >
然后后面会有几个summary元素,如:
<Summary sTime="2/18/2009 - 16:24:04" eTime="2/18/2009 - 16:28:57" passed="1" failed="0" warnings="1" ></Summary>
我用一段代码,遍历所有的节点,然后弹出节点名字,几乎所有的其他节点都被遍历到并显示名字了了,可是就是没有这个summary,请问这是什么原因呢?
以下是我的vbs code:
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
[ 本帖最后由 yiyireal 于 2009-3-6 15:52 编辑 ] |
|