Re: Accessing "external" tables from within LuaExpat callbacks
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Accessing "external" tables from within LuaExpat callbacks
- From: Michael Bauroth <Michael.Bauroth@...>
- Date: 2009年4月20日 16:03:31 +0200
First of all thank you for your sample. Unfortunately the script
produces the same error. Only if I replace
stuff[#stuff+1]= attr
with
table.insert( stuff, #stuff + 1, attr )
the program works. The disadvantage of this: I can only use array based
table, because table.insert( stuff, name, attr ) isn't allowed and
stuff[ name ] = attr
produces the same error as before.
Regards
Micha
Elbers, H.P. schrieb:
A smal example:
#!/usr/bin/env lua
require("lxp")
local stuff = {}
xmldata="<Top><A/> <B a='1'/> <B a='2'/><B a='3'/><C a='3'/></Top>"
function doFunc(parser, name, attr)
if not (name == 'B') then return end
stuff[#stuff+1]= attr
end
local xml = lxp.new{StartElement = doFunc}
xml:parse(xmldata)
xml:close()
print(stuff[2].a)
==> 2