Question

I'm trying to get images inside links from enlive document. The following works:

(html/select nodes [:a :img])

But this way I only get the image nodes, I want the links too!

So the next step was

(html/select nodes [:a (html/has [:img])])

But for some reason this returns just an empty list. I tried to browse the documentation and read the source code and it seems this should return links with img tags as child but maybe I missed something (or this is a bug)

Was it helpful?

Solution

Okay, figured it out. This needs second set of brackets. Why? I tried to read the documentation but I'm not sure (something about and rules). Anyway, here is the answer.

(html/select nodes [[:a (html/has [:img])]])
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top