Great. Happy to help!

On Dec 13, 7:39 am, Linus Ericsson <oscarlinuserics...@gmail.com>
wrote:
> Thank you Tom!
>
> Exactly was I was looking for!
>
> I will TRY to add some documentation to clojuredocs.org just so people
> won't be that afraid, this xml-functionality is a very sane way of doing
> it, it's just takes a while to get used to it (I'll check that it's refered
> to the correct namespace as well).
>
> I guess next step would be making a clojar avaliable, but I have no clue on
> how to do that yet.
>
> /Linus
>
> 2011/12/13 Tom Faulhaber <tomfaulha...@gmail.com>
>
>
>
>
>
>
>
> > Hi Linus,
>
> > Zippers and their associated helpers are woefully undocumented, so I'm
> > not surprised you fell into the swamp.
>
> > I think that the help you're looking for can be found in the
> > clojure.data contrib project (seehttps://github.com/clojure/data.zip
> > for the source andhttp://clojure.github.com/data.zipfor the
> > autodoc).
>
> > Using that, the xpathy thing you're looking for is something like
> > this:
>
> > (ns play.xml-example
> >  (:require [clojure.zip :as zip]
> >            [clojure.data.zip :as zf]
> >            [clojure.xml :as xml])
> >  (:use clojure.data.zip.xml))
>
> > (def mz (zip/xml-zip (xml/parse "dataabove.xml")))
>
> > (defn get-all-dimensions []
> >   (doseq [id (xml-> mz zf/descendants (attr= :id "2") zf/children :e
> > (attr :id))]
> >    (println (apply str id))))
>
> > Note that I had to make a couple of fixes to the above XML to make it
> > right.
>
> > I hope that's useful!
>
> > Tom
>
> > On Dec 12, 7:06 am, Linus Ericsson <oscarlinuserics...@gmail.com>
> > wrote:
> > > Hello!
>
> > > What's the clever way to read the E-tags "thisone" and "andthis" in the
> > > XML-file below given I don't know their id on beforehand?
>
> > > <a>
> > >   <b>bla bla</b>
> > >   <b>bla bla</b>
> > >   <c id="wanted">
> > >     <d id="1">
> > >       <e id="notthisone"/></d>
> > >     <d id="2">
> > >       <e id="thisone"/>
> > >       <e id="andthis"/></d>
> > >    <d id="3">
> > >       <e id="not-intresting"></d>
> > > </a>
>
> > > My solution so far would be something like
>
> > > (def mz (zip/xml-zip (xml/parse "dataabove.xml")))
>
> > > (defn get-all-dimensions []
> > >   (filter #(and (= "2" (:id %)) (= :e (:tag %))) (zip/children mz))))
>
> > > but I'm looking for some descending solution
>
> > > (-> mz
> > >       (zip/down a)
> > >       (zip/down c :where (= :id "wanted"))
> > >       (zip/down d :where (= :id 2))
> > >       zip/children)
>
> > > (an xpath-like solution would most awesome)
>
> > > According to it's own page Enlive is not very good for xml and I cannot
> > > figure out the way to dynamically walk with zippers (like "go into the
> > tag
> > > :d with id=..."). Would Enlive work for my needs here?
>
> > > When I got this sorted out I will try my best to add some examples on
> > > clojuredocs.org, zippers is good but I don't know if it's for
> > everything.
>
> > > /Linus
>
> > --
> > 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

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