Module Xml_parser
Xml Light Parser
While basic parsing functions can be used in the Xml module, this module is providing a way to create, configure and run an Xml parser.
type xml= Xml_datatype.xmlAn Xml node is either
Element (tag-name, attributes, children)orPCData text
Xml Exceptions
type error_postype error_msg=type 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 occurred at.
val range : error_pos -> int * intGet the relative character range (in current line) the error occurred at.
val abs_range : error_pos -> int * intGet the absolute character range the error occurred at.
val pos : Stdlib.Lexing.lexbuf -> error_pos
type source=|SChannel of Stdlib.in_channel|SString of string|SLexbuf of Stdlib.Lexing.lexbufSeveral kind of resources can contain Xml documents.
val check_eof : t -> bool -> unitWhen a Xml document is parsed, the parser may check that the end of the document is reached, so for example parsing
"<A/><B/>"will fail instead of returning only the A element. You can turn on this check by settingcheck_eoftotrue(by default, check_eof is false, unlike in the original Xmllight).
val parse : ?do_not_canonicalize:bool -> t -> xmlOnce the parser is configured, you can run the parser on a any kind of xml document source to parse its contents into an Xml data structure.
When
do_not_canonicalizeis set, the XML document is given as is, without trying to remove blank PCDATA elements.