feed_parser/lib/xml.ex

22 lines
573 B
Elixir

defmodule FeedParser.XML do
@moduledoc """
A set of helpers for working with XML. To use this module, you must `require` it.
"""
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