In this case, you want the tag, which contains the attributes and contents, so you would drop the net.cgrand.enlive-html/text-node
part of the selector.
(defn getbyitemprop
"Extract node content from HTML"
[html value]
(e/select-nodes* (e/html-snippet html)
[(e/attr= :itemprop value)]))
(getbyitemprop
"<p itemprop=\"description\" src=\"testvalue\"> Some content I want to extract </p>"
"description")
;=> ({:tag :p,
; :attrs {:src "testvalue", :itemprop "description"},
; :content (" Some content I want to extract ")})
This works for dynamic strings of html, if you want more general transformations for files, or resources in general, take a look at the documentation for deftemplate
and defsnippet
.