Skip to content

Instantly share code, notes, and snippets.

@lhanson
Created August 24, 2011 19:02
Show Gist options
  • Save lhanson/1168880 to your computer and use it in GitHub Desktop.
Save lhanson/1168880 to your computer and use it in GitHub Desktop.
Enlive selector-step
(use '[net.cgrand.enlive-html :as html])
(def markup (html/html-resource (java.io.StringReader.
"<html><body><div><img src='1.png'/><div><img src='nested.png'/></div></div></body></html>")))
; I want to select the first img
; This selects all images, as expected
(html/select markup [:img])
;matches: ({:tag :img, :attrs {:src "1.png"}, :content nil} {:tag :img, :attrs {:src "nested.png"}, :content nil})
; How do I use first-of-type?
(html/select markup [:img html/first-of-type])
;matches: ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment