Xmlixir (xmlixir v0.1.0)

Copy Markdown

A small XML parser operating on UTF-8 binaries internally.

Parser input is stored as UTF-8 internally. UTF-8, BOM-marked UTF-16LE/ UTF-16BE, and declared ISO-8859-1 input are accepted. Other encodings must be converted before parsing.

Summary

Functions

Parses XML and always returns an Xmlixir.Document wrapper.

Scans one XML element and returns {element, unconsumed_binary}.

Scans one XML element and always returns an Xmlixir.Document wrapper.

Scans one XML element and wraps successful results in {:ok, result}.

Streams parser events from binary or chunked XML input.

Streams matching element nodes from a binary XML document.

Serializes an Xmlixir node or document wrapper to XML iodata.

Types

t()

@type t() :: %Xmlixir{
  attribute_nodes: term(),
  attributes: map(),
  children: [xml_node() | binary()],
  content: [xml_node() | binary()],
  dtd_id_attributes: term(),
  elementdef: term(),
  expanded_name: term(),
  language: term(),
  name: binary(),
  namespace: term(),
  nsinfo: term(),
  parents: term(),
  pos: term(),
  xmlbase: term()
}

xml_node()

@type xml_node() :: t()

Functions

attribute(node, name)

attributes(node)

children(node, name)

descendants(node, name)

file(path)

file(path, opts)

parse(xml)

parse(xml, opts)

parse_document(xml, opts \\ [])

@spec parse_document(binary(), keyword()) ::
  {:ok, Xmlixir.Document.t()} | {:error, term()}

Parses XML and always returns an Xmlixir.Document wrapper.

scan(xml)

Scans one XML element and returns {element, unconsumed_binary}.

scan(xml, opts)

scan_document(xml, opts \\ [])

@spec scan_document(binary(), keyword()) ::
  {Xmlixir.Document.t(), binary()} | {:error, term()}

Scans one XML element and always returns an Xmlixir.Document wrapper.

scan_result(xml, opts \\ [])

@spec scan_result(binary(), keyword()) ::
  {:ok, {t() | Xmlixir.Document.t(), binary()}} | {:error, term()}

Scans one XML element and wraps successful results in {:ok, result}.

stream_events(source, opts \\ [])

Streams parser events from binary or chunked XML input.

stream_nodes(xml, names, opts \\ [])

Streams matching element nodes from a binary XML document.

text(node)

to_iodata(node)

@spec to_iodata(t() | Xmlixir.Document.t() | [term()]) :: iodata()

Serializes an Xmlixir node or document wrapper to XML iodata.