HaXml
title: "HaXml" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["free-software-programmed-in-haskell", "xml-parsers", "software-using-the-gnu-lesser-general-public-license"] topic_path: "general/free-software-programmed-in-haskell" source: "https://en.wikipedia.org/wiki/HaXml" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::data[format=table title="infobox software"]
| Field | Value |
|---|---|
| author | Malcolm Wallace |
| latest release version | v1.25.13 |
| latest release date | |
| repo | https://github.com/HaXml/HaXml |
| programming language | Haskell |
| genre | library |
| license | LGPL 2.1 |
| :: |
| author = Malcolm Wallace | latest release version = v1.25.13 | latest release date = | repo = https://github.com/HaXml/HaXml | programming language = Haskell | genre = library | license = LGPL 2.1
HaXml is a collection of utilities for parsing, filtering, transforming, and generating Extensible Markup Language (XML) 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
HaXml provides a combinator library with a set of higher-order functions which process the XML documents after they are represented using the native Haskell data types. The basic data type is Content which represents the document subset of XML.
HaXml allows converting XML to Haskell data and vice versa, and XML to XML (by transforming or filtering). The common use of the HaXml's parser includes defining the method of traversing the XML data and it has the CFilter type (content filter), where type CFilter = Content - [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 (e.g., tags with certain name or all children of a specified tag).
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 (simplified version):
::code[lang=xml]
Haskell Radio http://www.example.com/radio/ Description of this podcast First item Second item ::The following content filter is constructed:
::code[lang=haskell] channel :: CFilter channel = tag "rss" /> tag "channel" ::
This filter is later used to get the title of the channel:
::code[lang=haskell] getTitle :: Content -> String getTitle doc = contentToStringDefault "Untitled Podcast" (channel /> tag "title" /> txt $ doc) ::
References
References
- "Release v1.25.13".
- (November 5, 2020). "Fast XML/HTML tools for Haskell: XML TypeLift and improved Xeno". Zenodo.
- "Readme".
- "Bidirectionalising HaXML".
- (January 6, 2007). "A Cookbook for the Haskell XML Toolbox with Examples for Processing RDF Documents". fhwedel Computer Science Department.
- (2008). "[[Real World Haskell]]". [[O'Reilly Media]].
- (September 1, 1999). "Haskell and XML: generic combinators or type-based translation?". ACM SIGPLAN Notices.
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::