Fix XML parsing

This commit is contained in:
Shadowfacts 2022-04-12 11:42:17 -04:00
parent a36dcc9535
commit 129061448a
1 changed files with 6 additions and 6 deletions

View File

@ -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