WechatPay v0.7.0 WechatPay.Utils.XMLParser View Source

Module to convert a XML string to map

Link to this section Summary

Functions

Convert the response XML string to map

Link to this section Functions

Link to this function parse(xml_string, root_element \\ "xml") View Source
parse(String.t(), String.t()) :: {:ok, map()} | {:error, WechatPay.Error.t()}

Convert the response XML string to map

Example

iex> WechatPay.Utils.XMLParser.parse("<xml><foo><![CDATA[bar]]></foo></xml>", "xml")
...> {:ok, %{foo: "bar"}}

iex> WechatPay.Utils.XMLParser.parse("<root><foo><![CDATA[bar]]></foo></root>", "root")
...> {:ok, %{foo: "bar"}}