lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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