Skip to content

Instantly share code, notes, and snippets.

@reedho
Created June 10, 2019 07:51
Show Gist options
  • Save reedho/9f3d1cfe2f932ada2a577addd0712791 to your computer and use it in GitHub Desktop.
Save reedho/9f3d1cfe2f932ada2a577addd0712791 to your computer and use it in GitHub Desktop.
Clojure data xml usage
(require '[clojure.data.xml :as xml])
;; `emit-str`
(xml/emit-str
(xml/sexp-as-element
[:Login
[:AgencyCode "agencycode"]
[:Username "XML_Agency"]
[:Password "Password@123"]]))
;; `emit`
(with-open [w (java.io.StringWriter.)]
(xml/emit
(xml/sexp-as-element
[:login [:user "x"] [:password "y"]])
w)
(.toString w))
;; `sexps-as-fragment`
(xml/emit-str
(xml/element
:hotels
{}
(xml/sexps-as-fragment
[:code 100]
[:code 200]
[:code 300])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment