Braintree.XML.Decoder (Braintree v0.15.0)

XML dumping tailored to encoding params sent by Braintree.

Summary

Functions

Converts an XML document, or fragment, into a map. Type annotation attributes are respected, but all other attributes are ignored.

Types

xml()

@type xml() :: binary()

Functions

load(xml)

@spec load(xml()) :: map()

Converts an XML document, or fragment, into a map. Type annotation attributes are respected, but all other attributes are ignored.

Examples

iex> Braintree.XML.Decoder.load("<a><b type='integer'>1</b><c>2</c></a>")
%{"a" => %{"b" => 1, "c" => "2"}}

iex> Braintree.XML.Decoder.load("<a><b type='string'>Jos&#233;</b></a>")
%{"a" => %{"b" => "José"}}

iex> Braintree.XML.Decoder.load("<a><b type='string'>First &amp; Last</b></a>")
%{"a" => %{"b" => "First & Last"}}

iex> Braintree.XML.Decoder.load("<a><b type='string'>&quot;air quotes&quot;</b></a>")
%{"a" => %{"b" => ~s("air quotes")}}