As explained in its docstring, clojure.data.xml/parse
accepts an InputStream
or Reader
, so that's what you need to provide:
(require '[clojure.data.xml :as xml]
'[clojure.java.io :as io])
(xml/parse (io/reader "data/small-sample.xml"))
Note that io/reader
attempts to treat strings as URIs as a first guess, then as local file names. You can use io/file
if you want to be explicit about dealing with a file ((io/reader (io/file ...))
). There's also io/resource
for looking things up on the classpath.