I'm not that familiar with Enlive, so I can't comment on the ease of that
approach.

However, the way I'd personally do it is that I'd make use of Crouton and
the zipper functions in clojure.zip and clojure.data.zip. A zipper is a
functional way of navigating an immutable data structure.

So first add Crouton and data.zip to your dependencies:

  [[crouton "0.1.2"]
   [org.clojure/data.zip "0.1.1"]]

Then use Crouton to parse the body of the response from clj-http:

  (crouton.html/parse (:body response))

This will give you a data structure that's compatible with clojure.xml, and
therefore compatible with the XML zipper functions

    (dzx/xml1-> (z/xml-zip parsed-html)
              dz/descendents
              (dzx/tag= "input")
              (dzx/attr= "name" "foo")

In the above case I'm using the following namespace aliases:

  (require '[clojure.zip :as z]
           '[clojure.data.zip :as dz]
           '[clojure.data.zip.xml :as dzx])

It's been a while since I've needed to traverse X/HTML in Clojure though,
so my code might be a little off.

- James

On 14 October 2015 at 22:53, Mike <m...@thefrederickhome.name> wrote:

> Thanks James!  You helped me get another step along the way, I got this
> working.
>
> Of course you mentioned Crouton; you should and I asked for advice on my
> approach.  So please allow me to expand the problem statement and you may
> advise me further...
>
> Once I get this HTML parsed, I know that somewhere buried in this page is
> an *<input>* tag that has *name="name"* attribute where I will specify
> the name value at run time.  I will need to be able to programmatically
> find this tag and pul some values out of it.  Will using *clj-tagsoup* or 
> *Crouton
> *make this location operation easier?  Perhaps even using *Enlive *might
> make it easier, since the location and path to the tag is not known; it
> must be located.
>
> On Wednesday, October 14, 2015 at 1:53:11 PM UTC-5, James Reeves wrote:
>>
>>
>> Crouton is an alternative HTML parsing library (that's coincidentally
>> written by me) and can be found at:
>> https://github.com/weavejester/crouton
>>
>> Crouton uses a slightly different output syntax, which is compatible with
>> Clojure's xml zipper functions, making it more suitable for document
>> searches and traversal (IMO).
>>
>> - James
>>
>>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to