2019-08-31 23:02:41 +00:00
|
|
|
defmodule FeedParser.XML do
|
2019-09-01 03:25:10 +00:00
|
|
|
@moduledoc """
|
|
|
|
A set of helpers for working with XML. To use this module, you must `require` it.
|
|
|
|
"""
|
|
|
|
|
2019-08-31 23:02:41 +00:00
|
|
|
import Record
|
|
|
|
|
|
|
|
defrecord :xmlElement, extract(:xmlElement, from_lib: "xmerl/include/xmerl.hrl")
|
|
|
|
defrecord :xmlAttribute, extract(:xmlAttribute, from_lib: "xmerl/include/xmerl.hrl")
|
|
|
|
defrecord :xmlText, extract(:xmlText, from_lib: "xmerl/include/xmerl.hrl")
|
|
|
|
|
|
|
|
@spec parse(data :: String.t()) :: tuple()
|
|
|
|
def parse(data) do
|
|
|
|
{doc, _} =
|
|
|
|
data
|
|
|
|
|> :binary.bin_to_list()
|
|
|
|
|> :xmerl_scan.string()
|
|
|
|
|
|
|
|
doc
|
|
|
|
end
|
|
|
|
end
|