On 23 Jan 2010, at 02:53, James Reeves wrote:

> On Jan 23, 2:29 am, David Cabana <drcab...@gmail.com> wrote:
>> What I'd like to get from 'tickets' is something like ( ["Alice"
>> ["foo"]]  ["Bob" ["bar" "baz"]]), that is, output that ties incidents
>> to customers. So far it has eluded me.
> 
> "xml->" just returns a sequence of matches. If you want nested
> matches, you'll need to put another loop in. Perhaps something like:
> 
> (defn tickets [xml]
>  (for [ticket (zf/xml-> xml :ticket)]
>    [(zf/xml1-> ticket :customer zf/text)
>     (zf/xml-> ticket :item zf/text)]))

The following is equally untested, but you can also just have xml-> call a 
function for each matching sub-element:

(defn ticket [xml]
  [(zf/xml1-> xml :customer zf/text)
    (zf/xml-> xml :item zf/text)])

(defn tickets [xml]
 (zf/xml-> xml :ticket ticket)))


-Steve

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

Reply via email to