Lazarus has some interesting examples, one of this is the XMLReader.
But who wants waste time to make gui forms with script language? Much easier to make it with a standard formdesigner and just load it on runtime...
require "vcl"
VCL = vcl
-- XMLFormToLua loads the exported XML form and converts it to lus script.
loadstring(VCL.XMLFormToLua("testform.xml"))()
-- We will need the Load button event as well
function reLoad()
TreeView1:Clear()
if TreeView1:LoadXML(FileNameEdit1.FileName) then else VCL.ShowMessage("ERROR") end
end
BitBtn1.OnClick = "reLoad"
-- Finally the TreeViewClick event handler, the original ListView replaced with more flexible StringGrid
function OnTreeClick(s)
if s:Selected() then
ListView1:Clear()
ListView1:LoadRowFromTable(0,{"Name","Value"})
t = s:GetDOMNode(s:Selected())
if t then
for k,v in pairs(t) do
if type(v)=="table" then
for kk,vv in pairs(v) do
-- use addrow(n) to insert at position instead of addrow()
ListView1:LoadRowFromTable(ListView1:AddRow(1),{kk,vv})
end
else
if k=="Name" then
Edit1.Text= v or ""
elseif k=="Value" then
Edit2.Text= v or ""
end
end
end
end
end
end