0
votes

clojure-xml/parse returns a map of an xml file.

(ns xml-lib.core
  ^{:author "Charles M. Norton",
    :doc "xml-lib is an xml parsing library built on clojure-xml.
        Created on June 26, 2012"} 
  (:require [clojure.string :as cstr])
  (:require [util.core :as utl])
  (:require [clojure.xml :as cjxml]))

(defn ret-xml-data
    "Returns a map of the supplied xml file."
    [xml-fnam]

    (let [test-file-nam (utl/open xml-fnam)]
    (cjxml/parse xml-fnam))

Is the returned map lazy, or should I pass the parse call into a lazy sequence function?

Thanks.

(ret-xml-data "test.xml")

returns (result truncated).

{:tag :TamperExport, :attrs {:xmlns "http://
2
If you want to parse XML with Clojure lazily, I'd recommend clojure.data.xml, which is the successor to what used to be in clojure-xml from clojure-contrib. - David J.

2 Answers

3
votes

the short anser is no, clojure-xml likely won't do what you want.

data.xml is the lazy sucessor to clojure-xml

https://github.com/clojure/data.xml

1
votes

It uses a SAX Parser under the hood, which will consume the entire xml document, so I assume that it will create the fully realized data structure.