Sablon.XML.Parser (sablon v0.4.4)

Copy Markdown View Source

A small, non-validating XML parser.

It is deliberately lenient and lossless enough to round-trip the parts of an Open Office XML package sablon touches: the XML declaration, processing instructions, comments, CDATA sections and namespace-prefixed element names are all preserved verbatim.

Summary

Functions

Decodes the five predefined XML entities plus numeric character references.

Parses an XML fragment. Namespace prefixes that are not declared in the fragment are kept as part of the element name, exactly like Nokogiri's XML.fragment/1 does.

Parses a complete XML document.

Parses binary into a simple tree of tuples without materialising a document. Mostly useful for testing the parser itself.

Functions

decode_entities(binary)

@spec decode_entities(binary()) :: binary()

Decodes the five predefined XML entities plus numeric character references.

fragment(binary)

@spec fragment(binary()) :: Sablon.XML.Document.t()

Parses an XML fragment. Namespace prefixes that are not declared in the fragment are kept as part of the element name, exactly like Nokogiri's XML.fragment/1 does.

parse(binary)

@spec parse(binary()) :: Sablon.XML.Document.t()

Parses a complete XML document.

simple_form(binary)

@spec simple_form(binary()) :: [tuple()]

Parses binary into a simple tree of tuples without materialising a document. Mostly useful for testing the parser itself.