this one is really making my head spin. There goes:
I've written a small app that queries an API and gets a xml with local weather, which then parses and structures into a card.
Everything was working fine initially, except that after a while I started getting "xmlerr: can't parse xml" on random occasions.
Retrying the same query sometimes resolves the issue, in other occasions it doesn't.
Now, I've attached the full stack if you wanted to try it out, but here's the relevant code that builds and launches the call to the API.
There's a function to build the API call ("costruisciChiamataAPI"), which then feeds the construction of the XML parsing.
Code: Select all
local citta, forecastGiornoArray, meteoOraArray
on mouseup
get URL costruisciChiamataAPI()
put it into risultato
put risultato into field "risultato"
pubblicaXML(ottieniNodoXML(risultato))
end mouseup
function costruisciChiamataAPI
local apiKey="&key=878a3350da6dda93ce4a0d3b30a8122e8242796e"
local apiURLhead="http://api.worldweatheronline.com/free/v1/weather.ashx?"
local apiURLfoot="&format=xml&num_of_days=5&lang=it"
get the text of field cittaInput
if it is empty then
answer "Errore, campo vuoto"
exit to top
end if
put it into citta
put "q=" & URLEncode(citta) into cittaTarget
put apiURLhead & cittaTarget & apiURLfoot & apiKey into chiamataAPI
return chiamataAPI
end costruisciChiamataAPI
function ottieniNodoXML albero
put revCreateXMLTree (albero, false, true, false) into tTree
if tTree is not an integer then
answer error "Problema con l'XML ricevuto, con nodo: " & tTree
return empty
end if
return tTree
end ottieniNodoXML
on pubblicaXML tTree
controllaCittaValida(tTree)
estraiDatiMeteoOra(tTree)
estraiDatiMeteoForecast(tTree)
revDeleteXMLTree tTree //cancella albero per liberare memoria
lock screen //alcuni elementi grafici non si aggiornano in tempo reale...
visualizzaForecast
visualizzaMeteoOra
unlock screen
end pubblicaXML
Could it be an issue of the remote server? Or could it be that I'm not doing something properly and Livecode runs out of memory? (Sorry, I'm really clueless!)
Thanks a gazillion!
Mike