I am trying to apply function for extracting content of one tag from xml on a collection of tags. Basically, I am trying to make a function that will extract content from xml, like this
(defn get-events
[xz]
(map (juxt
#(zf/xml1-> % :title zf/text)
#(zf/xml1-> % :performers :performer :name zf/text)
#(zf/xml1-> % :start_time zf/text)
#(zf/xml1-> % :stop_time zf/text))
(zf/xml-> xz :events :event)))
And my solution so far looks like this
(ns datamodel
(:use
[net.cgrand.enlive-html :as en-html ])
(:require
[clojure.zip :as z]
[clojure.xml :as xml ]
[clojure.data.zip.xml :as zf]
[clojure.java.io :as io]
))
(def data-url "http://api.eventful.com/rest/events/search? app_key=4H4Vff4PdrTGp3vV&keywords=music&location=Belgrade&date=Future")
(defn xz [url](z/xml-zip (xml/parse url)))
(defn xml-zipper [& tags](zf/xml-> (xz data-url) tags))
(defn func [& tags]#(zf/xml1-> (xml-zipper tags) % zf/text))
(def tags [:title :venue_name])
and in REPL when I try to apply func to tags like this
(map #((apply comp (reverse( func :events :event))) %) tags)
I get an empty collection ().