polysoup-0.6: Online XML parsing with polyparse and tagsoup

Safe HaskellNone
LanguageHaskell98

Text.XML.PolySoup.Combine

Contents

Description

The module provides some common XML tree parsing combinators. There are two main groups of combinators: XPath-like combinators and tag/forest combinators. Use combinators from the first group if possible, since they are generally easier too use and generate results in a lazy manner.

The second class contains more powerful combinators which can be used to parse the contents of an XML node in a generic way. Note, that combinators from the two groups can be interleaved -- you can use a forest parser to construct a tree predicate, but you can also use a tree predicate as an elementary forest parser (see the Text.XML.PolySoup.Parser module).

Synopsis

Predicate conversion

node :: Q (Tag s) a -> Q (XmlTree s) a Source

Make a tree-level predicate from a tag-level predicate.

XPath-like combinators

(>/>) :: Q (Tag s) a -> (a -> Q (XmlTree s) b) -> Q (XmlTree s) [b] infixr 2 Source

Combine a tag predicate with an XML predicate. The XML predicate can depend on the value of tag parser and will be called multiple times for tag children elements.

(</>) :: Q (Tag s) a -> Q (XmlTree s) b -> Q (XmlTree s) (a, [b]) infixr 2 Source

Combine the tag parser with the XML parser. The XML parser will be called multiple times for tag children elements.

(/>) :: Q (Tag s) a -> Q (XmlTree s) b -> Q (XmlTree s) [b] infixr 2 Source

Combine the tag parser with the XML parser. The XML parser will be called multiple times for tag children elements.

(//>) :: Q (Tag s) a -> Q (XmlTree s) b -> Q (XmlTree s) [b] infixr 2 Source

Similar to /> combinator but runs the XML parser for all descendant XML elements, not only for its children.

Tag/forest parsing combinators

join :: Q (Tag s) a -> (a -> P (XmlTree s) b) -> Q (XmlTree s) b Source

Combine the tag predicate with the forest parser which will be used to parse contents of the tag element.

joinP :: Q (Tag s) a -> P (XmlTree s) b -> Q (XmlTree s) (a, b) Source

Combine the tag predicate with the forest parser which will be used to parse contents of the tag element.

joinL :: Q (Tag s) a -> P (XmlTree s) b -> Q (XmlTree s) a Source

Combine the tag predicate with the orest parser which will be used to parse contents of the tag element. Only results of the tag predicate will be returned (the contents have to be successfully parsed, though).

joinR :: Q (Tag s) a -> P (XmlTree s) b -> Q (XmlTree s) b Source

Combine the tag predicate with the orest parser which will be used to parse contents of the tag element. Only results of the forest parser will be returned.

(>^>) :: Q (Tag s) a -> (a -> P (XmlTree s) b) -> Q (XmlTree s) b infixr 2 Source

Infix version of the join combinators.

(<^>) :: Q (Tag s) a -> P (XmlTree s) b -> Q (XmlTree s) (a, b) infixr 2 Source

Infix version of the joinP combinators.

(^>) :: Q (Tag s) a -> P (XmlTree s) b -> Q (XmlTree s) b infixr 2 Source

Infix version of the joinR combinators.

(<^) :: Q (Tag s) a -> P (XmlTree s) b -> Q (XmlTree s) a infixr 2 Source

Infix version of the joinL combinators.