Does clojure-xml/parse return a lazy sequence?

不羁岁月 提交于 2019-12-11 20:05:03

问题


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://

回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/11213083/does-clojure-xml-parse-return-a-lazy-sequence

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!