<<snip>> Taco wrote: ============= Here is a trivial example using LuaExpat: \starttext \startluacode require "lxp"; text = '<p>hello world</p>' callbacks = { EndElement = false, StartElement = false, Default = function (p, s) tex.sprint(s) end } p = lxp.new(callbacks) \stopluacode Some xml output: \directlua{p:parse(text)}!. \directlua{p:close()} \stoptext ============= Wonderful! Thanks Taco. Just for the record, for other Windows users, to get this working I downloaded luaexpat-1.1.win32-lua51.zip from http://luaforge.net/projects/luaexpat/files and from that I copied the following DLLs (from luaexpat-1.1.win32-lua51.zip) libexpat.dll lxp.dll into the following directory on my PC C:\Context\tex\texmf-mswin\bin\lib\lua (adapt to your ConText install) One question, in the minimal example below, the XML text: text = '<elem1> text <elem2/> more text </elem1>' parses fine *if* on a single line. If I break the text onto multiple lines, eg text = '<elem1> text <elem2/> more text </elem1>' it fails with ! LuaTeX error <main ctx instance>:3: unfinished string near ''<elem1> text <elem2/>'. } = lxp.new(callbacks)d \dodostartluacode ...d \directlua \zerocount {#1}} l.21 \stopluacode Why is this --- is this a catcode issue? Can you suggest a fix? Once again, thank you, as always, for sharing your expertise. Warm wishes Graham =============== Minimal Example ================ \startluacode require "lxp"; text = '<elem1> text <elem2/> more text </elem1>' callbacks = { StartElement = function (p, s) tex.sprint("Starting element: " ..s) end, EndElement = function (p, s) tex.sprint("Finishing element: " ..s) end, CharacterData = function (p, s) tex.sprint(s) end } p = lxp.new(callbacks) \stopluacode