OX is an XML integration into Objective-Caml, providing XML transducers based on pseudo-tree view. This gives a homogeneous view of XML within OCaml code, and lets users to manipulate such terms like any other ones, without constraint.
Pattern matching provides basic mechanisms for term decomposition.
let rec number_of_tag xml = XML match xml with | CDATA -> 0 | <_> _* as content </> -> 1 + (number_of_tag content) | _* -> Xml.fold_left (fun i elem -> i + (number_of_tag elem)) 0 xml
Embedded XML term provides fragment creation.
let mkHtm title body = XML { <HTML> <HEAD> <TITLE> title </> </> <BODY> body </> </> }