[Haskell-cafe] Using SAX
Larry Lee
llee454 at gmail.com
Thu Jul 21 21:13:36 CEST 2011
I'm new to Haskell and am trying to use the SAX module to parse an XML
file. I'm using the following code:
module FPHParser where
import Data.Text as Text
import Data.Maybe
import Text.XML.LibXML.SAX as SAX
import System.IO
f :: IO (Parser IO)
f =
do
let g = do
putStrLn ("g called.")
return True
let h msg = do
putStrLn (Text.unpack msg)
return False
p <- SAX.newParserIO (Just (Text.pack "test.xml"))
SAX.setCallback p SAX.reportError h
SAX.setCallback p SAX.parsedBeginDocument g
SAX.parseComplete p
return p
and am getting the following error when I parse a file with the
following contents:
<?xml version="1.0"?>
<html/>
[This is the error]
"Extra content at the end of the document"
This error seems to be coming from the LibSAX library, which is a C
library. But I think that my error is in my code, as the file is valid
XML.
Any help would be greatly appreciated!
More information about the Haskell-Cafe
mailing list