Reputation: 92
I have a xml-seq:
({:tag :foo, :attrs nil, :content nil})
And I need to parse it to a xml string to store in my memory like this:
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<foo></foo>"
Already tried clojure.data.xml/emit-str but without success, any tips?
Upvotes: 0
Views: 338
Reputation: 20944
You are using clojure.xml/parse
, switch to clojure.data.xml/parse
and your round-trip should work:
(clojure.data.xml/emit-str
(xml-seq (clojure.data.xml/parse
(java.io.ByteArrayInputStream.
(.getBytes (str "<foo></foo>"))))))
; => "<?xml version=\"1.0\" encoding=\"UTF-8\"?><foo></foo>"
Upvotes: 1