Getting Started with lua-e4x

How to get started with lua-e4x.

lua_e4x is a Lua implementation of E4X (ECMAScript for XML). It is modeled after the Adobe E4X implementation.

For more information, look at the page lua-e4x Documentation or check out the unit tests to see what the module can do.

I have listed an example below.


For installation instructions see !! file not found !!.

lua_e4x Overview

E4X is an idea which was introduced back in 2007 to describe a way to more easily work with XML data.

Though XML isn't as popular these days because JSON is used more often as a data-exchange format. However, XML isn't without its strengths and continues to be used today.

lua_e4x Basics

Usage Overview

Here is a simple example of working with XML using lua_e4x. First is the XML data file,

XML Example Data: 'spec/xml/test-01.xml'

<?xml version="1.0"?>
    <book ISBN="0942407296">
        <title>Baking Extravagant Pastries with Kumquats</title>
    <book ISBN="0865436401" publisher="Prentice Hall">
        <title>Emu Care and Breeding</title>

Lua E4X Basic Example

--== Imports

local E4X = require 'lua_e4x'
local File = require 'lua_files' -- soon not needed

--== Setup, Constants

local data, xml

--== Main

data = File.readFileContents( './spec/xml/test-01.xml' )
xml = E4X.parse( data )

-- this will find books with editor field and get last name
print( )

-- finds books with titles and loops through results
for i, title in do
    print( title:toString() )

Example Output

Baking Extravagant Pastries with Kumquats
Emu Care and Breeding