Module Xmlc.Tree

Tree representation of XML

type t =
| Element of {
name : Xmlm.name;
attributes : Xmlm.attribute list;
children : t list;
}
| Data of string(*

Type of a XML tree

*)
val make_element : ?attributes:Xmlm.attribute list -> ?children:t list -> Xmlm.name -> t

make_element ?attributes ?children name returns a new element node of an XML tree with name and optional children and attributes.

val make_data : string -> t

make_data v returns a new data element of an XML tree with value v.

val to_seq : t -> Xmlm.signal Stdlib.Seq.t

to_seq tree returns a sequence of XML signals that represent tree.

val pp : t Fmt.t

pp returns a pretty printer.

Currently this uses Xmlm to return an XML reprepresentation. In the future this might be made prettier with coloured printing and such.

Parser

val parser : t Parser.t

parser is a Xmlc parser that can be used to parse a XML tree from a stream of XML signals.

Parsing from XML trees

val parse : 'a Parser.t -> t -> 'a Lwt.t

parse parser tree applies parser on tree.

val parse_trees : 'a Parser.t -> t Stdlib.Seq.t -> 'a Lwt.t

parse_trees parser forrest applies parser[ on a sequence of trees [forrest].

Miscellaneous

val get_root_attribute : Xmlm.name -> t -> string option

get_root_attribute name tree returns the attribute value of attribute name from the root element of tree.