13.09.2022, 07:39
Adjust URL and all parameters as needed. The resulting sites table will have the data that you need.
Code:
url = 'http://192.168.1.1/WacMobileService/WebService1.asmx/GetWacStatuses?UserName=string&Password=string&GroupId=string&SubGroupId=string&bOnlyWithAlerts=string&RequiredAlertsBitmap=string&MaxResults=string'
data, err = require('socket.http').request(url)
log('result', data, err)
if not data then
return
end
sites = {}
callbacks = {
StartElement = function(p, tag)
ctag = tag
if tag == 'wSiteStatus' then
site = { status = {} }
state = 'site'
elseif tag == 'wBulkStatus' then
status = {}
state = 'status'
end
end,
EndElement = function(p, tag)
ctag = nil
if tag == 'wSiteStatus' then
state = nil
if site.SiteId then
sites[ site.SiteId ] = site
end
elseif tag == 'wBulkStatus' then
state = 'site'
if status.BulkId then
site.status[ status.BulkId ] = status
end
end
end,
CharacterData = function(p, value)
value = value:trim()
if #value == 0 or not ctag then
return
end
if state == 'site' then
site[ ctag ] = value
elseif state == 'status' then
status[ ctag ] = value
end
end
}
parser = require('lxp').new(callbacks)
parser:parse(data)
parser:close()
log(sites)