module Xml:sig..end
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).
(c)Copyright 2002-2003 Nicolas Cannasse
type xml =
| |
Element of |
| |
PCData of |
Element (tag-name, attributes, children) or PCData textval parse_file : string -> xmlval parse_in : Pervasives.in_channel -> xmlval parse_string : string -> xmltype error_pos
type error_msg =
| |
UnterminatedComment |
| |
UnterminatedString |
| |
UnterminatedEntity |
| |
IdentExpected |
| |
CloseExpected |
| |
NodeExpected |
| |
AttributeNameExpected |
| |
AttributeValueExpected |
| |
EndOfTagExpected of |
| |
EOFExpected |
typeerror =error_msg * error_pos
exception Error of error
exception File_not_found of string
val error : error -> stringval error_msg : error_msg -> stringval line : error_pos -> intval range : error_pos -> int * intval abs_range : error_pos -> int * intexception Not_element of xml
exception Not_pcdata of xml
exception No_attribute of string
val tag : xml -> string
val pcdata : xml -> stringpcdata xdata returns the PCData value of the xml node.
Raise Xml.Not_pcdata if the xml is not a PCDataval attribs : xml -> (string * string) listattribs 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 elementval attrib : xml -> string -> stringattrib 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 elementval children : xml -> xml listchildren xdata returns the children list of the xml node
Raise Xml.Not_element if the xml is not an elementval iter : (xml -> unit) -> xml -> unititer f xdata calls f on all children of the xml node.
Raise Xml.Not_element if the xml is not an elementval map : (xml -> 'a) -> xml -> 'a listmap f xdata is equivalent to List.map f (Xml.children xdata)
Raise Xml.Not_element if the xml is not an elementval fold : ('a -> xml -> 'a) -> 'a -> xml -> 'afold f init xdata is equivalent to
List.fold_left f init (Xml.children xdata)
Raise Xml.Not_element if the xml is not an elementval to_string : xml -> stringval to_string_fmt : xml -> string