Search code examples
xmlvbscripthp-uft

XML file not loading while trying in UFT (VB script)


I have a requirement to read XML file from UFT and extract few values. Unfortunately by below code is not working. I see that XML file itself is not loading, I have tried with multiple files and still no success. Please help me with any suggestions.

Below is my code to open Response.xml file

set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async= False
path = "C:\Users\axxxx\Desktop\Response.xml" 
If xmlDoc.LoadXml(path) then
msgbox " file loaded "
else
msgbox "file not loaded"
End If

Above code displays file not loaded. Am using UFT 14.50 and Windows 10

I have tried many xml files and nothing is getting loaded. Is it something to do with MSXML, I have checked that MSXML6.dll (Highest version) is available in system 32 folder. Please help me with this.


Solution

  • Thank you I found the solution. New code is below. Just changed XMLDoc.LoadXML to XMLDoc.Load and it worked

    set xmlDoc = CreateObject("Microsoft.XMLDOM")
    xmlDoc.Async= False
    path = "C:\Users\axxxx\Desktop\Response.xml" 
    If xmlDoc.Load(path) then
    msgbox " file loaded "
    else
    msgbox "file not loaded"
    End If