Legend:
Library
Module
Module type
Parameter
Class
Class type
Xml Light
Xml Light is a minimal Xml parser & printer for OCaml. It provide few functions to parse a basic Xml document into an OCaml data structure and to print back the data structures to an Xml document.
Xml Light has also support for DTD (Document Type Definition).
| Elementof string * (string * string) list * xml list
| PCDataof string
An Xml node is either Element (tag-name, attributes, children) or PCData text
Xml Parsing
For easily parsing an Xml data source into an xml data structure, you can use theses functions. But if you want advanced parsing usage, please look at the XmlParser module. All the parsing functions can raise some exceptions, see the Exceptions section for more informations.
Several exceptions can be raised when parsing an Xml document :
Xml.Error is raised when an xml parsing error occurs. the Xml.error_msg tells you which error occured during parsing and the Xml.error_pos can be used to retreive the document location where the error occured at.
Xml.File_not_found is raised when and error occured while opening a file with the Xml.parse_file function or when a DTD file declared by the Xml document is not found (see the XmlParser module for more informations on how to handle the DTD file loading).
If the Xml document is containing a DTD, then some other exceptions can be raised, see the module Dtd for more informations.
attribs xdata returns the attribute list of the xml node. First string if the attribute name, second string is attribute value. Raise Xml.Not_element if the xml is not an element
attrib xdata "href" returns the value of the "href" attribute of the xml node (attribute matching is case-insensitive). Raise Xml.No_attribute if the attribute does not exists in the node's attribute list Raise Xml.Not_element if the xml is not an element