1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
define_tag(
'getalerts',
-namespace='weatherbug_',
-required='key',
-required='zip',
-priority='replace',
-description='Returns alert conditions for given zip code.'
);
local('url' = 'http://' + #key + '.api.wxbug.net/getalerts.aspx');
local('getparams') = array(
'acode' = #key,
'zipcode' = #zip
);
local('response') = include_url(
#url,
-getparams=#getparams
);
#response->replace(' xmlns:aws="http://www.aws.com/aws"','')&replace('aws:','');
local('xmldata') = xml(#response);
local('out' = array);
if(string(#xmldata->extract('//alerts/text()')->first) == 'No Alerts at this time.');
#out->insert('No Alerts at this time.');
else;
local('alerttypes') = #xmldata->extract('//alert/type/text()');
local('alerttitles') = #xmldata->extract('//alert/title/text()');
iterate(#alerttypes, local('i'));
local('map' = map);
#map->insert(#i = #alerttitles->get(loop_count));
#out->insert(#map);
/iterate;
/if;
return(@#out);
/define_tag;
|