Created
August 24, 2011 19:02
-
-
Save lhanson/1168880 to your computer and use it in GitHub Desktop.
Enlive selector-step
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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