edit

added
1.0

ns
clojure.zip

type
function

(edit loc f & args)

Replaces the node at this loc with the value of (f node args)

                (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>"