-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | wrapper for expat, the fast XML parser -- -- Expat (http://expat.sourceforge.net/) is a stream-oriented XML -- parser written in C. It is known for being simple and fast. -- -- There are already nice XML libraries in the Text.XML hierarchy. The -- reason to use Expat is when speed is of concern. From a benchmark that -- compares getting the length of the root node of a HaXml tree -- (presumably forcing parsing the entire file) against running an Expat -- parser with a registered start node handler, Expat is about 12 times -- faster. This is not a fair benchmark; HaXml does a lot more than this -- Expat library. But if Expat suffices, it is good for what it does. @package hexpat @version 0.2 -- | This module wraps the Expat API directly with IO operations -- everywhere. Basic usage is: -- --
    --
  1. Make a new parser: newParser.
  2. --
  3. Set up callbacks on the parser: setStartElementHandler, -- etc.
  4. --
  5. Feed data into the parser: parse or parseChunk.
  6. --
module Text.XML.Expat.IO data Parser -- | Create a Parser. The encoding parameter, if provided, overrides -- the document's encoding declaration. newParser :: Maybe Encoding -> IO Parser -- | parse data feeds lazy bytestring data into a parser -- and returns True if there was no parse error. parse :: Parser -> ByteString -> IO Bool -- | Encoding types available for the document encoding. data Encoding ASCII :: Encoding UTF8 :: Encoding UTF16 :: Encoding ISO88591 :: Encoding -- | The type of the "element started" callback. The first parameter is the -- element name; the second are the (attribute, value) pairs. type StartElementHandler = String -> [(String, String)] -> IO () -- | The type of the "element ended" callback. The parameter is the element -- name. type EndElementHandler = String -> IO () -- | 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. type CharacterDataHandler = String -> IO () -- | Attach a StartElementHandler to a Parser. setStartElementHandler :: Parser -> StartElementHandler -> IO () -- | Attach an EndElementHandler to a Parser. setEndElementHandler :: Parser -> EndElementHandler -> IO () -- | Attach an CharacterDataHandler to a Parser. setCharacterDataHandler :: Parser -> CharacterDataHandler -> IO () -- | 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. parseChunk :: Parser -> ByteString -> Bool -> IO (Bool) -- | The Expat.Tree module provides a simplified interface to parsing, that -- returns a tree of the XML structure. It is written using the -- lower-level bindings in the Text.XML.Expat.IO module. (Note -- that this is not a lazy parse of the document: as soon as the root -- node is accessed, the entire document is parsed.) module Text.XML.Expat.Tree -- | parse enc doc parses lazy bytestring XML content -- doc with optional encoding override enc and returns -- the root Node of the document if there were no parsing errors. parse :: Maybe Encoding -> ByteString -> Maybe Node -- | Simplistic XML tree representation. data Node Element :: String -> [(String, String)] -> [Node] -> Node eName :: Node -> String eAttrs :: Node -> [(String, String)] eChildren :: Node -> [Node] Text :: String -> Node -- | Encoding types available for the document encoding. data Encoding ASCII :: Encoding UTF8 :: Encoding UTF16 :: Encoding ISO88591 :: Encoding instance Show Node