talira

SweetXml

Query XML in Elixir with XPath sigils

open sourceMITfree

SweetXml (the Hex package sweet_xml) is a thin Elixir wrapper around Erlang's :xmerl that turns XML into Elixir values. You query a document with XPath through the ~x sigil, with modifiers for lists, text and entities, and xmap builds nested maps from several paths at once. It also streams large files, from File.stream! or element by element, so a whole document needn't be in memory. It's maintained in the Kbrw GitHub organization under the MIT licence.

Problems it solves

  • pull values out of an XML document in Elixir
  • parse an XML API response into Elixir maps
  • read a large XML file in Elixir without loading it all into memory

Features

  • query XML with XPath through the ~x sigil
  • map several XPath queries into nested Elixir maps with xmap
  • stream large XML files from File.stream! or element by element
  • Hex package sweet_xml

Alternatives

The same job

These do what SweetXml does.

  1. Saxy Fast streaming XML SAX parser and encoder for Elixir
  2. Erlsom XML parser for Erlang: SAX parsing and XML Schema based data binding
  3. XML Builder (Elixir) Generate XML in Elixir from tuples and builder functions

Compare SweetXml with the top 3