ClojureDocs

Nav

Namespaces

edit

clojure.zip

Available since 1.0
  • (edit loc f & args)
Replaces the node at this loc with the value of (f node args)
1 Example
(require '[clojure.xml :as xml]
         '[clojure.zip :as zip])

;; get xml with content added to root child
(let [root      (zip/xml-zip (xml/parse-str "<root><child/></root>"))
      child     (zip/down root)
      new-child (zip/edit child #(assoc-in % [:content] "content"))
      new-root  (zip/root new-child)]
  (xml/emit-str new-root))
;;=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root><child>content</child></root>"
See Also

zips all the way up and returns the root node, reflecting any changes.

Added by damianfijorek

Creates a new zipper structure. branch? is a fn that, given a node, returns true if can have c...

Added by phreed

Replaces the node at this loc, without moving

Added by loeschzwerg
0 Notes
No notes for edit