This is the first paragraph.
This parser uses [RapidXML](http://rapidxml.sourceforge.net/) to parse XML
content.
*MIT license* © Marcin Kalicinski 2006, 2009, Gaspard Bucher 2014.
## Installation
With [luarocks](http://luarocks.org):
$ luarocks install xml
## Usage example
local data = xml.load(some_xml)
local xml_string = xml.dump(some_table)
--]]-----------------------------------------------------
local lub = require 'lub'
local lib = lub.Autoload 'xml'
local ipairs, pairs, insert, type,
match, tostring =
ipairs, pairs, table.insert, type,
string.match, tostring
local parser = lib.Parser()
-- Current version respecting [semantic versioning](http://semver.org).
lib.VERSION = '1.1.2'
lib.DEPENDS = { -- doc
-- Compatible with Lua 5.1 to 5.3 and LuaJIT
'lua >= 5.1, < 5.4',
-- Uses [Lubyk base library](http://doc.lubyk.org/lub.html)
'lub >= 1.0.3, < 2',
}
-- nodoc
lib.DESCRIPTION = {
summary = "Very fast xml parser based on RapidXML",
detailed = [[
This module is part of the Lubyk project.
Main features are:
- Fast and easy to use
- Complete documentation
- Based on proven code (RapidXML)
- Full test coverage
Read the documentation at http://doc.lubyk.org/xml.html.
]],
homepage = "http://doc.lubyk.org/"..lib.type..".html",
author = "Gaspard Bucher",
license = "MIT",
}
-- nodoc
lib.BUILD = {
github = 'lubyk',
includes = {'include', 'src/bind', 'src/vendor'},
platlibs = {
linux = {'stdc++'},
macosx = {'stdc++'},
},
-- FIXME: Implement platform flags for lut.Builder and see how it works with
-- luarocks /EHsc is needed for exception handling.
platflags = {
win32 = {'EHsc'},
},
}
--[[
# Lua table format
This xml library uses string keys in Lua tables to store
attributes and numerical keys for sub-nodes. Since the 'xml'
attribute is not allowed in XML, we use this key to store the
tag. Here is an example of Lua content:
## Lua
{xml='document',
{xml = 'article',
{xml = 'p', 'This is the first paragraph.'},
{xml = 'h2', class = 'opt', 'Title with opt style'},
},
{xml = 'article',
{xml = 'p', 'Some ', {xml = 'b', 'important'}, ' text.'},
},
}
## XML
And the equivalent xml:
#txt
This is the first paragraph.
Some important text.