package SZXX

  1. Overview
  2. Docs

Basic XML types and accessor functions

type attr_list = (string * string) list
val sexp_of_attr_list : attr_list -> Sexplib0.Sexp.t
val compare_attr_list : attr_list -> attr_list -> int
val equal_attr_list : attr_list -> attr_list -> bool
type element = {
  1. tag : string;
  2. attrs : attr_list;
  3. text : string;
  4. children : element list;
}
val sexp_of_element : element -> Sexplib0.Sexp.t
val compare_element : element -> element -> int
val equal_element : element -> element -> bool
val get_attr : attr_list -> string -> string option

Convenience function to access attributes by name

val preserve_space : attr_list -> bool

Convenience function to check whether an element has attribute xml:space="preserve"

val unescape : string -> string

SZXX.Xml.DOM.unescape "Fast & Furious 🏎️" returns "Fast & Furious 🏎️"

val dot : string -> element -> element option

el |> dot "row" returns the first immediate <row> child of element el

val dot_text : string -> element -> string option

el |> dot "row" returns the text of the first immediate <row> child of element el

val filter_map : string -> f:(element -> 'a option) -> element -> 'a list

el |> filter_map "row" ~f returns all filtered f <row> children of element el

val at : int -> element -> element option

el |> at 3 returns the nth (0-based indexing) immediate child of element el.

val at_s : string -> element -> element option

Same as at but takes a string argument. This allows at_s to be used in get together with dot and dot_text

val get : (element -> element option) list -> element -> element option

get el [dot "abc"; dot "def"] is equivalent to el |> dot "abc" |> Option.bind ~f:(dot "def") Convenience function to chain multiple dot and at calls to access nested elements.

OCaml

Innovation. Community. Security.