HaXml
HaXml is a collection of utilities for parsing, filtering, transforming, and generating Extensible Markup Language documents using the programming language Haskell.
Overview
HaXml utilities include:- XML parser
- XML validator
- a separate error-correcting parser for HTML
- pretty-printers for XML and HTML
- stream parser for XML events
- translator from DTD to Haskell
- translator from XML Schema definitions to Haskell data types
Content which represents the document subset of XML.HaXml allows converting XML to Haskell data and vice versa, and XML to XML. The common use of the HaXml's parser includes defining the method of traversing the XML data and it has the
CFilter type, where type CFilter = Content -> . It means that this function defined by the user will take a fragment of an XML data and either return more fragments or none at all. This approach allows to choose XML elements satisfying certain conditions.Example
In the chapter 22 "Extended Example: Web Client Programming" of the Real World Haskell by Bryan O'Sullivan, Don Stewart, and John Goerzen, the following example is considered. The XML file looks like this :http://www.example.com/radio/
The following content filter is constructed:
channel :: CFilter
channel = tag "rss" /> tag "channel"
This filter is later used to get the title of the channel:
getTitle :: Content -> String
getTitle doc = contentToStringDefault "Untitled Podcast"