Hey guys
i have this piece of code, where i try to load an eve-central API key (which is a server located XML file) and have it save it locally for further use. (i want to read from that XML, parse it / use values)
I have it now save the entire part of the XML system they use, based on the URL i give it, but then i have trouble loading the XML’s parameters (headers). Now the code i am building on seems a bit overdone, but it’s mainly for testing purposes, to see what my options are and what to built on. Question is: what are my options? End goal: download a LARGE amount of data, formatted in an XML order (eve central.com) and use parts of it for further calculations. (so for instance, i now ask for ID 34, stats from region 10000002. it gives me buy, sell and all volumes, min, max, median, etc and writes it to an xml file for later use)
let me note i am an amateur coder with limited C and JAVA knowledge and basically only know a bit about the structure of LUA and some basic coding. Almost totally new to codea and trying to learn as much as i can the next few weeks
code i use now:
-----------------------------------------------
local VALUE = 1
function setup()
print("-- run check: loading eve central")
market = nil
http.request("http://api.eve-central.com/api/marketstat?&typeid=34®ionlimit=10000002", loadxml, failxml)
end
function loadxml(inp)
market = inp
local file = os.getenv("HOME").."/Documents/market.xml"
local xml = inp
print("-- created file "..file)
writefiles(file,xml)
readFiles(file)
end
function writefiles(file,xml)
print("-- start write -- ")
print("write in "..file)
io.output(io.open(file,"w"))
io.write(xml)
io.close()
print("-- write done --")
end
function readFiles(file)
print("--start read --")
print("read from "..file)
io.input(io.open(file,"r"))
local li
for i in io.lines() do print(i) end
print("-- read done --")
end
function failxml()
print("xml download failed")
end
function draw()
background(40, 40, 50)
strokeWidth(5)
if market ~= nil then
text(market, WIDTH / 2, HEIGHT/2)
fill(255)
textWrapWidth(WIDTH)
else
text("loading", WIDTH / 2, HEIGHT/2)
end
end
---------------------------------------------