Namespaces

 
1.0.0-SNAPSHOT Arrow_down_16x16
  • (parse s)
  • (parse s startparse)
Parses and loads the source s, which can be a File, InputStream or
String naming a URI. Returns a seq of tree of the xml/element struct-map,
which has the keys :tag, :attrs, and :content. and accessor fns tag,
attrs, and content. Other parsers can be supplied by passing
startparse, a fn taking a source and a ContentHandler and returning
a parser

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source net/cgrand/xml.clj:82 top

(defn parse
  "Parses and loads the source s, which can be a File, InputStream or
  String naming a URI. Returns a seq of tree of the xml/element struct-map,
  which has the keys :tag, :attrs, and :content. and accessor fns tag,
  attrs, and content. Other parsers can be supplied by passing
  startparse, a fn taking a source and a ContentHandler and returning
  a parser"
  ([s] (parse s startparse-sax))
  ([s startparse]
    (let [loc (atom (-> {:type :document :content nil} xml-zip))
          metadata (atom {})
          content-handler (handler loc metadata)]
      (startparse s content-handler)
      (map #(if (instance? clojure.lang.IObj %) (vary-meta % merge @metadata) %)
        (-> @loc z/root :content)))))
Vars in net.cgrand.xml/parse: -> defn instance? let map merge vary-meta deref
Used in 0 other vars

Comments top

No comments for parse. Log in to add a comment.