‘QTP的结果文件RES中的XML文件
sResultsXML = “C:\Documents and Settings\Administrator\桌面\Test1\Res3\Report\Results.xml”
‘需要的模版文件XSL
sDetailedXSL = “D:\Program Files\HP\QuickTest Professional\dat\PDetails.xsl”
‘调用转换函数输出HTML
ApplyXSL sResultsXML, sDetailedXSL, “c:\tt.html”
‘转换函数
Public Function ApplyXSL(ByVal inputXML, ByVal inputXSL, ByVal outputFile)
sXMLLib = “MSXML.DOMDocument”
Set xmlDoc = CreateObject(sXMLLib)
Set xslDoc = CreateObject(sXMLLib)
xmlDoc.async = False
xslDoc.async = False
xslDoc.load inputXSL
xmlDoc.load inputXML
outputText = xmlDoc.transformNode(xslDoc.documentElement)
outputText=replace(outputText,”UTF-16″,”gb2312″)
Set FSO = CreateObject(“Scripting.FileSystemObject”)
Set outFile = FSO.CreateTextFile(outputFile,True)
outFile.Write outputText
outFile.Close
Set outFile = Nothing
Set FSO = Nothing
Set xmlDoc = Nothing
Set xslDoc = Nothing
Set xmlResults = Nothing
End Function