1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.XML do
8 def string_from_xpath(_, :error), do: nil
10 def string_from_xpath(xpath, doc) do
12 {:xmlObj, :string, res} = :xmerl_xpath.string('string(#{xpath})', doc)
19 if res == "", do: nil, else: res
22 Logger.debug("Couldn't find xpath #{xpath} in XML doc")
27 def parse_document(text) do
31 |> :binary.bin_to_list()
32 |> :xmerl_scan.string(quiet: true)
37 Logger.debug("Couldn't parse XML: #{inspect(text)}")
41 Logger.debug("Couldn't parse XML: #{inspect(text)}")