dom-parser-3.1.0: Simple monadic DOM parser

Safe HaskellNone




Parsing element's content

parseContent Source #


:: Monad m 
=> (Text -> Either Text a)

Content parser, return error msg if value is not parsed

-> DomParserT Identity m a 

Parses content inside current tag. It expects current element set consists of exactly ONE element.

Getting current element's properties

getCurrentName :: Monad m => DomParserT Identity m Name Source #

Returns name of current element.

Since: 1.0.0

getCurrentContent :: Monad m => DomParserT Identity m (Maybe Text) Source #

Get current content. If current element contains no content or have inner elements then Nothing returned

Since: 1.0.0

checkCurrentName :: Monad m => NameMatcher -> DomParserT Identity m () Source #

If name of current tag differs from first argument throws PENotFound with tag name replaced in last path's segment. Useful for checking root document's element name.


maybeReadContent Source #


:: Typeable a 
=> (Text -> Maybe a)

Content or attribute reader

-> Text

Content or attribute value

-> Either Text a 

If reader returns Nothing then resulting function returns 'Left "error message"'. Typeable is used for generating usefull error message.

Since: 1.0.0

readContent :: (Read a, Typeable a) => Text -> Either Text a Source #

Tries to read given text to value using Read. Useful to use with parseContent and parseAttribute. Content is stripped before reading.

readBool :: Text -> Either Text Bool Source #

Since: 1.0.0

readChar :: Text -> Either Text Char Source #

Expects text to be single character

Since: 1.0.0