Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
In my QV, I have macro to call webservice
function getAirportWSDL(vInput)
vURL = "http://www.webservicex.com/airport.asmx/getAirportInformationByISOCountryCode?CountryAbbrviation="+ vInput
'set txt1 = ActiveDocument.Variables("vXMLSent")
'txt1.setContent "Null", true
'Create xmlhttp opject
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.open "GET", vURL, false
xmlhttp.setRequestHeader "Content-Type", "text/xml"
xmlhttp.send ""
result = xmlhttp.responseText
result = replace(result, ">", ">")
result = replace(result, "<", "<")
set txt = ActiveDocument.Variables("vXMLReceived")
txt.setContent result, true
'getAirportWSDL = vInput
End Function
-----------------------------------------------------------------------------------------
in my load script,after reloading, it is not fetching any values to vXMLReceived
let vXMLReceived = ' ';
LET Creat = getAirportWSDL( 'BH');
Any help, would be appreciated.
Regards,
Umesh.
You should consider Toni's good advice since a load statement will help you parse the XML properly. If you tell more about how you intend to use the data in your application it would be easier for us to give you further advice.
For a small XML-payload like this service it is rather straight forward anyway to parse it manually. Where do you prefer to have the code? In the load script or in VBScript? VBScript has some limitations as to how you can run it and how efficiently it will run on a server. If you do everything in the load script it will be quite easy to do the same in Qlik Sense in the future whereas a VBScript solution has to be converted.
You can't access the ActiveDocument from a VBscript-function that you call from a Load Script. The ActiveDocument hasn't been intialized yet. So you will have to return the result as a return result from the function:
getAirportWSDL = result
End Function
and then the variable Creat get the result as a value.
LET Creat = getAirportWSDL('BH');
I would suggest that you rename the variable to resultAirport
LET resultAirport = getAirportWSDL('BH');
This variable you can easily access in your application once the Load Script has finished running and the application has started.
It looks like your macro only makes a HTTP GET to a web source and retrieves XML data. Why do you not just load this as an XML source directly in the load script?
Hi Peter,
Thanks, a lot.
Would, appreciate, if you Can please let me know how to parse xml string resultAirportXML.
You should consider Toni's good advice since a load statement will help you parse the XML properly. If you tell more about how you intend to use the data in your application it would be easier for us to give you further advice.
For a small XML-payload like this service it is rather straight forward anyway to parse it manually. Where do you prefer to have the code? In the load script or in VBScript? VBScript has some limitations as to how you can run it and how efficiently it will run on a server. If you do everything in the load script it will be quite easy to do the same in Qlik Sense in the future whereas a VBScript solution has to be converted.
Hi Peter,
Thanks, in that case, would prefer to have, XML string parsing, in QV LOAD script.
If you consider your question answered you could close this thread and I will have something for you on your new question on how to parse XML in the Load Script.
Hi Peter,
Thanks.
If you start a new question with for example "XML string parsing, in QV LOAD script" as a title - I can respond and upload something I have as a response to that.
Thanks