Module Ez_html.Xml

Xml Parsing
val parse_file : ?⁠check:bool -> string -> Xml_types.xml

Parse the named file into an Xml data structure.

val parse_in : Stdlib.in_channel -> Xml_types.xml

Read the content of the in_channel and parse it into an Xml data structure.

val parse_string : string -> Xml_types.xml

Parse the string containing an Xml document into an Xml data structure.

Xml Exceptions
type error = Xml_types.error_msg * Xml_types.error_pos
exception Error of error
exception File_not_found of string
val error : error -> string

Get a full error message from an Xml error.

val error_msg : Xml_types.error_msg -> string

Get the Xml error message as a string.

val line : Xml_types.error_pos -> int

Get the line the error occurred at.

val range : Xml_types.error_pos -> int * int

Get the relative character range (in current line) the error occurred at.

val abs_range : Xml_types.error_pos -> int * int

Get the absolute character range the error occurred at.

Xml Functions
exception Not_element of Xml_types.xml
exception Not_pcdata of Xml_types.xml
exception No_attribute of string
val tag : Xml_types.xml -> string

tag xdata returns the tag value of the xml node. Raise Xml.Not_element if the xml is not an element

val pcdata : Xml_types.xml -> string

pcdata xdata returns the PCData value of the xml node. Raise Xml.Not_pcdata if the xml is not a PCData

val attribs : Xml_types.xml -> (string * string) list

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

val attrib : Xml_types.xml -> string -> string

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

val children : Xml_types.xml -> Xml_types.xml list

children xdata returns the children list of the xml node Raise Xml.Not_element if the xml is not an element

val iter : (Xml_types.xml -> unit) -> Xml_types.xml -> unit

iter f xdata calls f on all children of the xml node. Raise Xml.Not_element if the xml is not an element

val map : (Xml_types.xml -> 'a) -> Xml_types.xml -> 'a list

map f xdata is equivalent to List.map f (Xml.children xdata) Raise Xml.Not_element if the xml is not an element

val fold : ('a -> Xml_types.xml -> 'a) -> 'a -> Xml_types.xml -> 'a

fold f init xdata is equivalent to List.fold_left f init (Xml.children xdata) Raise Xml.Not_element if the xml is not an element

Xml Printing
val to_string : Xml_types.xml -> string

Print the xml data structure into a compact xml string (without any user-readable formatting ).

val to_string_fmt : Xml_types.xml -> string

Print the xml data structure into an user-readable string with tabs and lines break between different nodes.