Lather.Xml.Builder (lather v1.0.42)

View Source

XML builder for creating SOAP envelopes.

Provides functionality to build XML documents from Elixir data structures, specifically optimized for SOAP envelope construction.

Summary

Functions

Builds XML from the given data structure.

Builds XML from a data structure without XML declaration.

Builds XML string from a map structure.

Escapes XML special characters in text content.

Functions

build(data)

@spec build(map()) :: {:ok, String.t()} | {:error, any()}

Builds XML from the given data structure.

Parameters

  • data - Elixir data structure (map) to convert to XML

Examples

iex> {:ok, xml} = Lather.Xml.Builder.build(%{"soap:Envelope" => %{"soap:Body" => %{"operation" => %{}}}})
iex> String.contains?(xml, "<soap:Envelope>")
true
iex> String.contains?(xml, "<operation/>")
true

build_fragment(data)

@spec build_fragment(map()) :: {:ok, String.t()} | {:error, any()}

Builds XML from a data structure without XML declaration.

Useful for building fragments that will be embedded in larger documents.

build_xml_string(data)

@spec build_xml_string(map()) :: String.t()

Builds XML string from a map structure.

escape_text(text)

@spec escape_text(String.t()) :: String.t()

Escapes XML special characters in text content.