Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@arohner
Created August 24, 2011 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arohner/1168833 to your computer and use it in GitHub Desktop.
Save arohner/1168833 to your computer and use it in GitHub Desktop.
Clojure zippers with HTML
;; requires [org.ccil.cowan.tagsoup/tagsoup "1.2"]
(defn startparse-tagsoup [s ch]
(let [p (new org.ccil.cowan.tagsoup.Parser)]
(. p (setContentHandler ch))
(. p (parse s))))
(defn parse-html-string [html]
(xml/parse (new org.xml.sax.InputSource
(new java.io.StringReader html))
startparse-tagsoup))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment