
\starttext

\startluacode
dofile "xmlparser.lua"

xmlparser.starttag = function (tag, attributes)
  if #(table.keys(attributes))>0 then
      table.print(attributes, "START " .. tag)
  else
      print("START " .. tag)
  end 
end

xmlparser.endtag = function (tag)
  print("END " .. tag)
end

xmlparser.data = function (text)
  print("DATA [[" .. text .. ']]')
end

xmlparser.comment = function (text) 
  print("COMMENT [[" .. text .. ']]')
end

xmlparser.pi = function (text)     
  print("PI [[" .. text .. ']]')
end

xmlparser.parse("demo.xml")

\stopluacode


\stoptext
