Skip to content

Instantly share code, notes, and snippets.

@patrickt
Created December 17, 2016 01:55
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 patrickt/6b6b98e9a986ac70f5af5e5dbd1de80b to your computer and use it in GitHub Desktop.
Save patrickt/6b6b98e9a986ac70f5af5e5dbd1de80b to your computer and use it in GitHub Desktop.
{-
Given a file at /tmp/lol.xml
<!DOCTYPE html>
<body>
lol!
</body>
-}
import qualified Text.XML as X
import qualified Text.HTML.DOM as HTML
getPrologue :: X.Document -> Maybe X.Doctype
getPrologue = X.prologueDoctype . X.documentPrologue
-- trying to get the prologue with html-conduit
getPrologue <$> HTML.readFile "/tmp/lol.xml"
-- yields Nothing. but if you try it with xml-conduit
getPrologue <$> X.readFile X.def "/tmp/lol.xml"
-- you get back `Just (Doctype {doctypeName = "html", doctypeID = Nothing})`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment