talira

Fast streaming XML SAX parser and encoder for Elixir

open sourceMITfree

Saxy is an XML parser and encoder for Elixir that follows the XML 1.0 (Fifth Edition) specification. It parses with SAX events through a handler module, can stream large files, and can also parse a document into a simple DOM-like form. Its encoder builds XML from that simple form or from structs through the Saxy.Builder protocol. It has no XPath; its README points to Saxmerl for turning documents into the format SweetXml reads. Install it from Hex as saxy.

Problems it solves

  • parse a huge XML file in Elixir without loading it all into memory
  • build and encode XML from Elixir structs
  • parse XML faster than xmerl in an Elixir app

Features

  • SAX parser with event handler callbacks
  • streaming parsing of large XML files
  • parse to a simple DOM-like form
  • XML encoder with a Builder protocol for structs

Limitations

  • No XSD or DTD support: a DOCTYPE declaration is skipped.1
  • Only UTF-8 encoded documents are supported.1

Alternatives

The same job

These do what Saxy does.

  1. SweetXml Query XML in Elixir with XPath sigils
  2. XML Builder (Elixir) Generate XML in Elixir from tuples and builder functions
  3. Erlsom XML parser for Erlang: SAX parsing and XML Schema based data binding

Compare Saxy with the top 3