lua-users home
lua-l archive

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


Ok, to make the question simpler ... :)

I want to fill an table (local or global ) through reading a XML file with use of LuaExpat. Has eventually somebody a short example to do that? Any help is highly appreciated.

Best Regards
Micha


Michael Bauroth schrieb:
Hi,

I used a simple example from LuaExpat (something like this):


local lom = require "lxp"
plugin = {}

function cb( tag, attribute, value )
  plugin[ attribute ] = value
end

local callbacks = {
  StartElement = function( parser, name, attributes )
    for _, attribute in pairs( attributes ) do
      cb( name, attribute, attributes[ attribute ] )
    end
  end,
  EndElement = function( parser, name ) end,
  CharacterData = false
}
local xml_file = "info.plist"
local parser = lxp.new( callbacks )
local file = assert( io.open( xml_file, "r" ) )
parser:parse( file:read( "*all" ) )
file:close();
collectgarbage()
parser:parse()
parser:close()


Everytime I try to modify a table in the referenced method "cb", the application stops with an accessviolation. What I'm doing wrong?

Best Regards
Micha