hexpat-0.1: wrapper for expat, the fast XML parser




This module wraps the Expat API directly, with IO.


Parser Setup

newParser :: Maybe String -> IO ParserSource

Create a Parser. The optional parameter is the default character encoding, and can be one of

  • "US-ASCII"
  • "UTF-8"
  • "UTF-16"
  • "ISO-8859-1"


parse :: Parser -> String -> Bool -> IO BoolSource

parse data False feeds mode data into a Parser. The end of the data is indicated by passing True for the final parameter. parse returns False on a parse error.

Parser Callbacks

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

The type of the "element started" callback. The first parameter is the element name; the second are the (attribute, value) pairs.

type EndElementHandler = String -> IO ()Source

The type of the "element ended" callback. The parameter is the element name.

type CharacterDataHandler = String -> IO ()Source

The type of the "character data" callback. The parameter is the character data processed. This callback may be called more than once while processing a single conceptual block of text.

setStartElementHandler :: Parser -> StartElementHandler -> IO ()Source

Attach a StartElementHandler to a Parser.

setEndElementHandler :: Parser -> EndElementHandler -> IO ()Source

Attach an EndElementHandler to a Parser.

setCharacterDataHandler :: Parser -> CharacterDataHandler -> IO ()Source

Attach an CharacterDataHandler to a Parser.