Generate XML in Elixir from tuples and builder functions
open sourceMITfree
XML Builder is an Elixir library for generating XML, inspired by Jim Weirich's builder library for Ruby. Each node is a tuple of a name, an attributes map and its content or child list, built by hand or with helper functions such as document and element, and generate turns the tree into an XML string. It handles namespaces, DOCTYPE declarations, the declared encoding, standalone documents and pretty or compact formatting. Content is escaped by default, with CDATA, already-safe and raw iodata content as explicit opt-outs, and generate_iodata skips building a single binary for large documents such as sitemaps.
Problems it solves
- generate an XML document such as a sitemap or feed from an Elixir app
- build XML for a SOAP or partner API request in Elixir without string templates
- make sure the XML my Elixir code writes is properly escaped
Features
- XML nodes as {name, attributes, content} tuples or document/element helper calls
- Escapes content by default, with CDATA, safe and raw iodata opt-outs
- Namespaces, DOCTYPE declarations, encoding and standalone declarations
- Pretty-printed or compact output
- generate_iodata for large documents without one big binary
Alternatives
The same job
These do what XML Builder (Elixir) does.
