24.02.2019, 00:16
(30.01.2019, 21:19)Erwin van der Zwart Wrote: Hi,
Is already in the script but this sample uses the object names instead of GA’s.
Change in all lines grp.update('Weather precipitation', ... to grp.update('1/1/1', ... etcetera
BR,
Erwin
require('socket.http')
forecast = {}
function parsetag(parser, tag, attributes)
if tag == '27/3/0' then
table.insert(forecast, {})
elseif tag == '27/3/1' then
forecast[ #forecast ].symbol = attributes.name
elseif tag == '27/3/2' then
forecast[ #forecast ].precipitation = attributes.value
elseif tag == '27/3/3' then
forecast[ #forecast ].wind_direction = attributes.code
elseif tag == '27/3/4' then
forecast[ #forecast ].wind_speed = attributes.mps
elseif tag == '27/3/6' then
forecast[ #forecast ].temperature = attributes.value
elseif tag == '27/3/5' then
forecast[ #forecast ].pressure = attributes.value
end
end
url = 'http://www.yr.no/place/United_Kingdom/England/London/varsel.xml'
data, err = socket.http.request(url)
if data then
require('lxp').new({
StartElement = parsetag
}):parse(data)
grp.update('27/3/7', tonumber(forecast[1].precipitation))
grp.update('27/3/8', forecast[1].symbol)
grp.update('27/3/9', forecast[1].wind_direction)
grp.update('27/3/10', tonumber(forecast[1].wind_speed))
grp.update('27/3/11', tonumber(forecast[1].temperature))
grp.update('27/3/12', tonumber(forecast[1].pressure))
--log(forecast)
else
alert('Fetch failed: ' .. tostring(err))
end
Still not getting any value, what am i doing wrong. : ?