利用MSXML的DOMDocument对象取出XML的节点

在QTP里使用VBS,取出QTP生成的Results.xml中的TimeTick节点。

Dim myXML

'myXML = "C:\Sample\Results.xml"
Call ShowNode(myXML,"TimeTick")

Public Function ShowNode(myfile,mytag)

 Dim xmlDoc, objNodeList, plot
 
 Set xmlDoc = CreateObject("Msxml2.DOMDocument")
 xmlDoc.load myfile
 Set objNodeList = xmlDoc.getElementsByTagName(mytag)
 
 If objNodeList.length > 0 then
  For each x in objNodeList
   plot=x.Text
   Print plot
  Next
 Else
  msgbox chr(34) & mytag & chr(34) & " field not found."
 End If
End Function

你可能感兴趣的:(xml,vbs,qtp,MSXML,results.xml)