Xml-Light is a minimal XML parser & printer for OCaml. It provide functions to parse an XML document into an OCaml data structure, work with it, and print it back to an XML document. It support also DTD parsing and checking, and is entirely written in OCaml, hence it does not require additional C library.
Here's two small sample of Xml-Light in action :
let x = Xml.parse_string "<a href='url'>TEXT<begin/><end/></a>" in Printf.printf "XML formated = \n%s" (Xml.to_string_fmt x);
let x = Xml.parse_file "myfile.xml" in let dtd = Dtd.parse_file "myfile.dtd" in let x = Dtd.prove (Dtd.check dtd) "start" x in print_endline (Xml.to_string x)
You can also read the online HTML Documentation.
To access the sources of this project, you can check them out from CVS repository. This is recommanded since this way you'll be sure to get latest version with fixes. Use the following commands :
cvs -d:pserver:[email protected]:/cvsroot login (enter empty password) cvs -d:pserver:[email protected]:/cvsroot co ocaml/xml-light
Other way is to download a source ZIP here.