package SZXX
Library
Module
Module type
Parameter
Class
Class type
Basic XML types and accessor functions
type attr_list = (Base.string * Base.string) Base.list
val sexp_of_attr_list : attr_list -> Sexplib0.Sexp.t
type element = {
tag : Base.string;
attrs : attr_list;
text : Base.string;
children : element Base.list;
}
val sexp_of_element : element -> Sexplib0.Sexp.t
val get_attr : attr_list -> Base.string -> Base.string Base.option
Convenience function to access attributes by name
Convenience function to check whether an element has attribute xml:space="preserve"
val unescape : Base.string -> Base.string
SZXX.Xml.DOM.unescape "Fast & Furious 🏎️"
returns "Fast & Furious 🏎️"
val dot : Base.string -> element -> element Base.option
el |> dot "row"
returns the first immediate <row>
child of element el
val dot_text : Base.string -> element -> Base.string Base.option
el |> dot "row"
returns the text of the first immediate <row>
child of element el
val filter_map :
Base.string ->
f:(element -> 'a Base.option) ->
element ->
'a Base.list
el |> filter_map "row" ~f
returns all filtered f <row>
children of element el
val at : Base.int -> element -> element Base.option
el |> at 3
returns the nth (0-based indexing) immediate child of element el
.
val at_s : Base.string -> element -> element Base.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 Base.option) Base.list ->
element ->
element Base.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.