Safe Haskell | None |
---|
Some helpers to parse documents with Text.XML.Cursor.
Extract single element
readT :: Text -> Cursor -> TextSource
Grab node content by element name.
pair cur = (readT "fst" cur, readT "snd" cur)
readC :: Read a => Text -> Cursor -> aSource
Extract a read-able type from a content of a node with given name.
age = readC "age" :: Cursor -> Integer
Extract from multiple elements
type Dict = HashMap Text TextSource
Very generic type to catch server reply when you don't care about types.
readDict :: Axis -> Cursor -> DictSource
Apply an axis and extract a key-value from child elements.
invokeWS … (CursorParser . readDict $ laxElement "WebScaleResponse" &/ laxElement "BigDataResult")
dictBy :: Text -> ResponseParser DictSource
Simple parser to grab a flat response by an element name.
result <- invokeWS … (dictBy "BigDataResult") case HM.lookup "SuccessError" result of …