aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/xml/xml.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma/web/xml/xml.ex')
-rw-r--r--lib/pleroma/web/xml/xml.ex19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/pleroma/web/xml/xml.ex b/lib/pleroma/web/xml/xml.ex
new file mode 100644
index 000000000..22faf72df
--- /dev/null
+++ b/lib/pleroma/web/xml/xml.ex
@@ -0,0 +1,19 @@
+defmodule Pleroma.Web.XML do
+ def string_from_xpath(xpath, doc) do
+ {:xmlObj, :string, res} = :xmerl_xpath.string('string(#{xpath})', doc)
+
+ res = res
+ |> to_string
+ |> String.trim
+
+ if res == "", do: nil, else: res
+ end
+
+ def parse_document(text) do
+ {doc, _rest} = text
+ |> :binary.bin_to_list
+ |> :xmerl_scan.string
+
+ doc
+ end
+end