     cattrlist <- peekArray0 nullPtr cattrs
     attrlist <- mapM peekCString cattrlist
     handler name (pairwise attrlist)
+-- |Attach a StartElementHandler to a Parser.
 setStartElementHandler :: Parser -> StartElementHandler -> IO ()
 setStartElementHandler (Parser p) handler = do
   handler' <- wrapStartElementHandler handler

-- XML_* in most cases anyway...  :(
{#context lib = "expat" prefix = "XML"#}

newtype Parser = Parser {#type Parser#}
asParser :: Ptr () -> Parser
asParser ptr = Parser ptr
unParser :: Parser -> Ptr ()
unParser (Parser p) = p
{#fun unsafe XML_ParserCreate as parserCreate {`String'} -> `Parser' asParser#}
{#fun unsafe XML_ParserFree as parserFree {unParser `Parser'} -> `()'#}

{#fun XML_Parse as parse
    {unParser `Parser', `String' &, `Bool'} -> `Int'#}

type StartElementHandler  = String -> [(String,String)] -> IO ()
type EndElementHandler    = String -> IO ()
type CharacterDataHandler = String -> IO ()

type CStartElementHandler = Ptr () -> CString -> Ptr CString -> IO ()

  h ptr cdata len = do
    data_ <- peekCStringLen (cdata, fromIntegral len)
    handler data_
-- |Attach an CharacterDataHandler to a Parser.
setCharacterDataHandler :: Parser -> CharacterDataHandler -> IO ()
setCharacterDataHandler (Parser p) handler = do
  handler' <- wrapCharacterDataHandler handler
