Xmlixir.Query (xmlixir v0.1.0)

Copy Markdown

String based XPath queries, mappings, and tag streams built on Xmlixir's native DOM.

Import this module to use the ~x sigil. Modifiers are s for strings, l for lists, e for native Xmlixir nodes, k for keyword maps, o for optional values, and i or f for integer and float conversion.

Summary

Functions

Parses a binary, iodata value, or enumerable of binary chunks into an Xmlixir node.

Parses query input and returns the core tagged result without raising.

Returns a lazy stream of every element node as {tag, node} pairs.

Returns a lazy stream of parser events from binary or chunked XML input.

Returns a lazy stream of {tag, node} pairs for matching element names.

Builds a map or keyword list by applying nested XPath specs.

Runs a native DOM query and applies the result modifiers in the query spec.

Types

doc()

@type doc() :: binary() | iodata() | Enumerable.t()

spec()

@type spec() :: %Xmlixir.XPathSpec{
  cast_to: term(),
  is_keyword: term(),
  is_list: term(),
  is_optional: term(),
  is_value: term(),
  namespaces: term(),
  path: term(),
  transform_fun: term()
}

Functions

add_namespace(spec, prefix, uri)

parse(document, options \\ [])

@spec parse(doc(), keyword()) :: Xmlixir.t() | Xmlixir.Document.t()

Parses a binary, iodata value, or enumerable of binary chunks into an Xmlixir node.

parse!(document, options \\ [])

@spec parse!(doc(), keyword()) :: Xmlixir.t() | Xmlixir.Document.t()

Strict alias for parse/2.

parse_result(document, options \\ [])

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

Parses query input and returns the core tagged result without raising.

sigil_x(path, modifiers \\ "")

stream(document, options \\ [])

Returns a lazy stream of every element node as {tag, node} pairs.

stream!(document, options \\ [])

stream_events(document, options \\ [])

Returns a lazy stream of parser events from binary or chunked XML input.

stream_tags(document, tags, options \\ [])

Returns a lazy stream of {tag, node} pairs for matching element names.

stream_tags!(document, tags, options \\ [])

transform_by(spec, fun)

xmap(parent, mapping, options \\ false)

Builds a map or keyword list by applying nested XPath specs.

xpath(parent, spec, subspec \\ [])

Runs a native DOM query and applies the result modifiers in the query spec.