Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Lua
  3. SLAXML

SLAXML

MITLuav0.8

A pure-Lua SAX-like streaming XML parser with optional DOM builder and serialization.

GitHubGitHub
165 stars45 forks0 contributors

What is SLAXML?

SLAXML is a pure-Lua SAX-like streaming XML parser that reads XML input in a single pass and emits events for elements, attributes, text, and other nodes. It solves the problem of parsing XML in Lua environments where robust, non-pattern-based parsing is needed, especially for documents with namespaces, CDATA, comments, and complex attribute values. The library includes an optional DOM parser for building and manipulating XML as Lua tables, with serialization back to XML.

Target Audience

Lua developers who need to parse, generate, or manipulate XML data within Lua applications, such as those working on game mods, configuration files, data interchange, or tools that process XML-based formats.

Value Proposition

Developers choose SLAXML because it is a pure-Lua solution that is more robust than simple pattern-based parsers, correctly handling edge cases like unescaped '>' in attributes and providing both streaming and DOM interfaces. Its optional DOM parser with serialization allows for easy XML manipulation and round-tripping, all without external dependencies.

Overview

SAX-like streaming XML parser for Lua

Use Cases

Best For

  • Parsing XML configuration files in Lua-based applications
  • Streaming large XML files in Lua without loading entire documents into memory
  • Building and manipulating XML documents as Lua tables for data interchange
  • Generating XML output from Lua data with pretty-printing and attribute sorting
  • Handling XML namespaces and CDATA sections in Lua scripts
  • Converting XML to structured Lua data for game mods or tooling

Not Ideal For

  • Applications requiring strict XML validation and error reporting for malformed documents
  • Projects that depend on DTDs for entity definitions or document structure validation
  • Systems needing to parse XML with custom entity expansions beyond the standard ones
  • High-performance environments where native XML parsers in C or other languages are preferred

Pros & Cons

Pros

Robust Real-World Handling

Correctly parses complex XML constructs like unescaped '>' in attributes and CDATA sections, which simpler pattern-based parsers often fail on, as emphasized in the README.

Pure Lua Convenience

Implemented in a single Lua file (or two with DOM), requiring no external dependencies, making it easy to integrate into Lua projects without setup overhead.

Flexible Parser Modes

Offers both a streaming SAX parser for low-memory usage on large files and an optional DOM parser with round-trip serialization for easy manipulation and output.

Whitespace and Serialization Control

Provides options to strip whitespace and serialize DOM with pretty-printing and attribute sorting, enhancing readability and diff-friendliness, as shown in the examples.

Cons

Lax XML Validation

Admits in the README that it allows syntactically-invalid XML without errors, such as mismatched tags or unescaped ampersands, which can lead to incorrect parsing in strict scenarios.

Missing Advanced Features

Lacks support for DTDs, XInclude, custom entities, and proper encoding handling, limiting its use with standards-compliant XML that relies on these features.

Serialization Pitfalls

Serialization can produce invalid XML if namespace prefixes are mismatched, as it ignores nsURI in favor of nsPrefix, requiring manual management of xmlns attributes, as warned in the documentation.

Frequently Asked Questions

Quick Stats

Stars165
Forks45
Contributors0
Open Issues4
Last commit1 year ago
CreatedSince 2013

Tags

#dom-parser#sax-parser#streaming-parser#xml-parser#data-parsing#lua#xml-serialization#xml-processing#pure-lua

Built With

L
Lua

Included in

Lua4.5k
Auto-fetched 1 day ago

Related Projects

json.luajson.lua

A lightweight JSON library for Lua

Stars2,150
Forks377
Last commit2 years ago
lua-cmsgpacklua-cmsgpack

A self contained Lua MessagePack C implementation.

Stars378
Forks122
Last commit4 years ago
lua-pblua-pb

Lua Protocol Buffers

Stars294
Forks91
Last commit8 years ago
LuLPegLuLPeg

A port of LPeg 100% written in Lua.

Stars268
Forks35
Last commit4 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub