On Sat, Jun 25, 2011 at 3:23 AM, dive_mw <dive...@googlemail.com> wrote: > Hi all, > can anybody help me, how to fix the following problem? I have a > function like this: > > (defn set-config-value > "sets a new value programatically to a config key" > [value & tags] > ;; set the new value and save the config file? > ;;(zip/edit tags (zip/xml-zip(load-config)) value ) > > ;; Save this config xml file with the changed xml content > (ds/spit "./config/config-tst.xml" > (with-out-str (lxml/emit (zip/root @config) :pad true))) > > ) > How can I set a new value to the element > => (set-config-value 5 :test) ?
Why not just nest the expressions: (ds/spit "./config/config-tst.xml" (with-out-str (lxml/emit (zip/root (zip/edit tags (zip/xml-zip (load-config)) value)) :pad true))) Now it will load the config (innermost ()), alter the value, then emit. Since you use with-out-str it's not going to be lazily reading the file at the same time it tries to write it, either; everything in with-out-str will evaluate, loading the config and changing it and generating the new XML in a string, and then the string will be returned, and ds/spit called at that point, overwriting the file. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en