Module Xml_light.Xml
Xml Data Structure
Xml Parsing
val parse_file : string -> xmlParse the named file into an Xml data structure.
val parse_in : Stdlib.in_channel -> xmlRead the content of the in_channel and parse it into an Xml data structure.
val parse_string : string -> xmlParse the string containing an Xml document into an Xml data structure.
val parse_string_with : XmlParser.t -> string -> xml
Xml Exceptions
type error_postype error_msg= Types.error_msg=|UnterminatedComment|UnterminatedString|UnterminatedEntity|IdentExpected|CloseExpected|NodeExpected|AttributeNameExpected|AttributeValueExpected|EndOfTagExpected of string|EOFExpectedtype error= error_msg * error_pos
exceptionError of errorexceptionFile_not_found of string
val error : error -> stringGet a full error message from an Xml error.
val error_msg : error_msg -> stringGet the Xml error message as a string.
val line : error_pos -> intGet the line the error occured at.
val range : error_pos -> int * intGet the relative character range (in current line) the error occured at.
val abs_range : error_pos -> int * intGet the absolute character range the error occured at.
Xml Functions
val tag : xml -> stringtag xdatareturns the tag value of the xml node. RaiseXml.Not_elementif the xml is not an element
val pcdata : xml -> stringpcdata xdatareturns the PCData value of the xml node. RaiseXml.Not_pcdataif the xml is not a PCData
val attribs : xml -> (string * string) listattribs xdatareturns the attribute list of the xml node. First string if the attribute name, second string is attribute value. RaiseXml.Not_elementif the xml is not an element
val attrib : xml -> string -> stringattrib xdata "href"returns the value of the"href"attribute of the xml node (attribute matching is case-insensitive). RaiseXml.No_attributeif the attribute does not exists in the node's attribute list RaiseXml.Not_elementif the xml is not an element
val children : xml -> xml listchildren xdatareturns the children list of the xml node RaiseXml.Not_elementif the xml is not an element
val iter : (xml -> unit) -> xml -> unititer f xdatacalls f on all children of the xml node. RaiseXml.Not_elementif the xml is not an element
val map : (xml -> 'a) -> xml -> 'a listmap f xdatais equivalent toList.map f (Xml.children xdata)RaiseXml.Not_elementif the xml is not an element
val fold : ('a -> xml -> 'a) -> 'a -> xml -> 'afold f init xdatais equivalent toList.fold_left f init (Xml.children xdata)RaiseXml.Not_elementif the xml is not an element
Xml Printing
val to_string : xml -> stringPrint the xml data structure into a compact xml string (without any user-readable formating ).
val to_string_fmt : xml -> stringPrint the xml data structure into an user-readable string with tabs and lines break between different nodes.
val to_human_string : xml -> string
module type X = sig ... end