Parse HTML documents using xml-conduit datatypes.

Version on this page:
LTS Haskell 22.12:
Stackage Nightly 2024-02-26:
Latest on Hackage:

See all snapshots html-conduit appears in

MIT licensed by Michael Snoyman
Maintained by [email protected]
This version can be pinned in stack with:html-conduit-,1892

Module documentation for

This package uses tagstream-conduit for its parser. It automatically balances mismatched tags, so that there shouldn’t be any parse failures. It does not handle a full HTML document rendering, such as adding missing html and head tags.

Simple usage example:

#!/usr/bin/env stack
{- stack --install-ghc --resolver lts-6.23 runghc
   --package http-conduit --package html-conduit
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text.IO        as T
import           Network.HTTP.Simple (httpSink)
import           Text.HTML.DOM       (sinkDoc)
import           Text.XML.Cursor     (attributeIs, content, element,
                                      fromDocument, ($//), (&/), (&//))

main :: IO ()
main = do
    doc <- httpSink "" $ const sinkDoc
    let cursor = fromDocument doc
    T.putStrLn "Chapters in the Yesod book:\n"
    mapM_ T.putStrLn
      $ cursor
      $// attributeIs "class" "main-listing"
      &// element "li"
      &/ element "a"
      &/ content


  • Remove an upper bound
  • Doc improvement

  • Allow xml-conduit 1.4


  • Add strict and lazy text parsing #66


  • Drop system-filepath

  • Fix a bug with double-unescaping of entities