Fix XML parsing
This commit is contained in:
parent
a36dcc9535
commit
129061448a
|
@ -11,15 +11,15 @@ defmodule FeedParser.XML do
|
||||||
|
|
||||||
@spec parse(data :: String.t()) :: {:ok, tuple()} | {:error, String.t()}
|
@spec parse(data :: String.t()) :: {:ok, tuple()} | {:error, String.t()}
|
||||||
def parse(data) do
|
def parse(data) do
|
||||||
{doc, _} =
|
|
||||||
try do
|
try do
|
||||||
|
{doc, _} =
|
||||||
data
|
data
|
||||||
|> :binary.bin_to_list()
|
|> :binary.bin_to_list()
|
||||||
|> :xmerl_scan.string()
|
|> :xmerl_scan.string()
|
||||||
|
|
||||||
|
{:ok, doc}
|
||||||
catch
|
catch
|
||||||
:exit, reason -> {:error, "parsing XML failed: #{inspect(reason)}"}
|
:exit, reason -> {:error, "parsing XML failed: #{inspect(reason)}"}
|
||||||
end
|
end
|
||||||
|
|
||||||
doc
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue