simple_xml_parser v0.0.1 SimpleXmlParser.Utils.PureXmlParser

The module can parse pure xml strings

Link to this section Summary

Types

A node object from parser, contains: node name, content, attributes.

Functions

Generate a structure that preserve xml hierarchy and help to parse it to another types

Link to this section Types

Link to this type

xml_node()

xml_node() :: {Atom.t(), List.t() | String.t(), List.t()}

A node object from parser, contains: node name, content, attributes.

Link to this section Functions

Link to this function

parse(xml_string)

parse(String.t()) :: xml_node()

Generate a structure that preserve xml hierarchy and help to parse it to another types

Examples

Parse a primitive object:
iex> SimpleXmlParser.Utils.PureXmlParser.parse("<return>Hello!</return>")
{:return, "Hello!", []}

Parse an object with attributes:
iex> SimpleXmlParser.Utils.PureXmlParser.parse("<return id='1'></return>")
{:return, [], [id: "1"]}

Parse a complex object:
iex> "<return><childs><child>1</child></childs></return>"
...> |> SimpleXmlParser.Utils.PureXmlParser.parse()
{:return, [{:childs, [{:child, "1", []}], []}], []}

iex> "<return><childs><child>1</child><child>2</child></childs></return>"
...> |> SimpleXmlParser.Utils.PureXmlParser.parse()
{:return, [{:childs, [{:child, "1", []}, {:child, "2", []}], []}], []}