hexpat-0.2: wrapper for expat, the fast XML parserSource codeContentsIndex
Text.XML.Expat.IO
Contents
Parser Setup
Parsing
Parser Callbacks
Lower-level Parsing Interface
Description

This module wraps the Expat API directly with IO operations everywhere. Basic usage is:

  1. Make a new parser: newParser.
  2. Set up callbacks on the parser: setStartElementHandler, etc.
  3. Feed data into the parser: parse or parseChunk.
Synopsis
data Parser
newParser :: Maybe Encoding -> IO Parser
parse :: Parser -> ByteString -> IO Bool
data Encoding
= ASCII
| UTF8
| UTF16
| ISO88591
type StartElementHandler = String -> [(String, String)] -> IO ()
type EndElementHandler = String -> IO ()
type CharacterDataHandler = String -> IO ()
setStartElementHandler :: Parser -> StartElementHandler -> IO ()
setEndElementHandler :: Parser -> EndElementHandler -> IO ()
setCharacterDataHandler :: Parser -> CharacterDataHandler -> IO ()
parseChunk :: Parser -> ByteString -> Bool -> IO (Bool)
Parser Setup
data Parser Source
newParser :: Maybe Encoding -> IO ParserSource
Create a Parser. The encoding parameter, if provided, overrides the document's encoding declaration.
Parsing
parse :: Parser -> ByteString -> IO BoolSource
parse data feeds lazy bytestring data into a parser and returns True if there was no parse error.
data Encoding Source
Encoding types available for the document encoding.
Constructors
ASCII
UTF8
UTF16
ISO88591
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.
Lower-level Parsing Interface
parseChunk :: Parser -> ByteString -> Bool -> IO (Bool)Source
parseChunk data False feeds strict ByteString 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.
Produced by Haddock version 2.1.0