Created
February 5, 2017 22:36
-
-
Save zaiste/1cc35b6541253452b81962fc1553e02f to your computer and use it in GitHub Desktop.
Create XML in Clojure
This file contains hidden or 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
| (ns clojure-xml-example.core | |
| (:require [clojure.data.xml :as xml]) | |
| (:gen-class)) | |
| (def bookshelf | |
| (xml/element :books {} | |
| (xml/element :book {:author "Stuart Halloway"} | |
| "Programming Clojure") | |
| (xml/element :book {:author "Christian Queinnec"} | |
| "Lisp in Small Pieces") | |
| (xml/element :book {:author "Harold Abelson, Gerald Jay Sussman"} | |
| "Structure and Interpretation of Computer Programs"))) | |
| (defn -main | |
| [] | |
| ;; work around dangerous default behaviour in Clojure | |
| (alter-var-root #'*read-eval* (constantly false)) | |
| (println (xml/emit-str bookshelf))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment