Xmlixir.XPath (xmlixir v0.1.0)

Copy Markdown

An XPath 1.0 selector for Xmlixir nodes.

Supported expressions include child and descendant paths, explicit axes, *, attributes, text(), node(), namespace mappings, variables, predicates, all XPath 1.0 core functions, and scalar expressions. Results remain binary-native Xmlixir nodes and values.

Summary

Functions

Parses an XPath expression into Xmlixir's binary-native AST.

Selects XPath results; malformed expressions are returned as [] for compatibility.

Selects XPath results or raises ArgumentError for invalid expressions/arguments.

Selects XPath results and preserves parser errors as tagged results.

Functions

parse(expression)

@spec parse(binary()) :: {:ok, Xmlixir.XPath.Parser.ast()} | {:error, term()}

Parses an XPath expression into Xmlixir's binary-native AST.

select(document, path, namespaces \\ [], options \\ [])

@spec select(
  Xmlixir.t() | Xmlixir.Document.t(),
  binary(),
  [{binary(), binary()}],
  keyword()
) :: [
  term()
]

Selects XPath results; malformed expressions are returned as [] for compatibility.

select!(document, path, namespaces \\ [], options \\ [])

@spec select!(
  Xmlixir.t() | Xmlixir.Document.t(),
  binary(),
  [{binary(), binary()}],
  keyword()
) :: [
  term()
]

Selects XPath results or raises ArgumentError for invalid expressions/arguments.

select_result(document, path, namespaces \\ [], options \\ [])

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

Selects XPath results and preserves parser errors as tagged results.