talira

XML parser for Erlang: SAX parsing and XML Schema based data binding

open sourceLGPL-3.0-or-laterfree

Erlsom is an Erlang library that parses and generates XML. It works as a SAX parser for documents of any size, as a simple DOM parser that produces the same 'simple form' as Xmerl, or as a data binder that validates a document against an XML Schema and turns it into Erlang records (and back). Documents can be fed in blocks from a stream, and it reads binaries directly, in Latin-1, UTF-8 or UTF-16.

Problems it solves

  • parse a large XML file in Erlang without loading it all into memory
  • turn XML documents into Erlang records using the XSD I already have
  • validate incoming XML against a schema in my Erlang service
  • generate XML from Erlang data structures for a SOAP-style API

Features

  • SAX parser for documents of any size
  • simple DOM mode with Xmerl's simple form
  • XML Schema data binding to Erlang records, and back to XML
  • streaming input in blocks of any size
  • works directly on Latin-1, UTF-8 and UTF-16 binaries

Limitations

  • Some XML Schema constraints are accepted but not enforced while parsing: most simple types are read as strings, and key and unique constraints aren't supported1

Alternatives

The same job

These do what Erlsom does.

  1. SweetXml Query XML in Elixir with XPath sigils
  2. Saxy Fast streaming XML SAX parser and encoder for Elixir
  3. XML Builder (Elixir) Generate XML in Elixir from tuples and builder functions

Compare Erlsom with the top 3