error while Convert xml to excel....
sub main
Dim xmlSource
Dim xmlXForm
Dim strErr
Dim strResult
Dim fso, file
Dim strPath
Const ForWriting = 2
Set xmlSource = CreateObject("MSXML.DOMDocument")
Set xmlXForm = CreateObject("MSXML.DOMDocument")
xmlSource.validateOnParse = True
xmlXForm.validateOnParse = True
xmlSource.async = False
xmlXForm.async = False
xmlSource.Load "C:\Users\username\Desktop\TC Reports\test.xml"
If Err.Number <> 0 Then
Err.Number <> 0
strErr = Err.Description & vbCrLf
strErr = strErr & xmlSource.parseError.reason & " line: " & _
xmlSource.parseError.Line & " col: " & _
xmlSource.parseError.linepos & _
" text: " & xmlSource.parseError.srcText
MsgBox strErr, vbCritical, "Error loading the XML"
End If
' This loads the XSLT transform
xmlXForm.Load "C:\Users\username\Desktop\TC Reports\test.xsl"
If Err.Number <> 0 Then
Err.Number <> 0
strErr = Err.Description & vbCrLf
strErr = strErr & xmlSource.parseError.reason & " line: " & _
xmlSource.parseError.Line & " col: " & _
xmlSource.parseError.linepos & _
" text: " & xmlSource.parseError.srcText
MsgBox strErr, vbCritical, "Error loading the Transform"
End If
' This transforms the data in xmlSource
strResult = xmlSource.transformNode(xmlXForm)
If Err.Number <> 0 Then
strErr = Err.Description & vbCrLf
strErr = strErr & xmlSource.parseError.reason & _
" line: " & xmlSource.parseError.Line & _
" col: " & xmlSource.parseError.linepos & _
" text: " & xmlSource.parseError.srcText
MsgBox strErr, vbCritical, "Error executing the Transform"
End If
Set fso = CreateObject("Scripting.FileSystemObject")
fso = CreateObject("Scripting.FileSystemObject")
strPath = "C:\Users\username\Desktop\TC Reports\test.txt"
' open the file
Set file = fso.opentextfile(strPath, ForWriting, True)
file = fso.opentextfile(strPath, ForWriting, )
' write the info to the file
file.write strResult
' close and clean up
file.Close
end sub
I get an error at
strResult = xmlSource.transformNode(xmlXForm)
msxml.dll
The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.
I checked the dlls in the bin folder of test complete. I see msxml4.dll? Could you pls give me some input.