Created
June 10, 2019 07:51
-
-
Save reedho/9f3d1cfe2f932ada2a577addd0712791 to your computer and use it in GitHub Desktop.
Clojure data xml usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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