Xml

:= {
    xml_declaration : [Given(Declaration), Missing],
    root : Node,
}

XML document tree and parser based on the XML 1.0 specification.

The parser supports optional XML declarations, attributes, nested elements, character data, CDATA sections, and self-closing elements.

is_eq : _

Compare two XML documents structurally.

xml_parser : Parser(Utf8, Xml)

Parse one XML document, including an optional declaration and trailing whitespace.

Attribute : { name : Str, value : Str }

An XML attribute name and decoded value.

TextEncoding : [
    Utf8Encoding,
    OtherEncoding(Str),
]

Text encoding declared by an XML declaration.

Declaration : {
    version : Version,
    encoding : [Given(TextEncoding), Missing],
}

Version and optional encoding from an XML declaration.

Version

Xml.Version :: # (opaque)

An XML 1.x version, storing the digit after 1..

is_eq : _

Compare two XML versions.

new : U8 -> Version

Construct an XML 1.x version from the digit after 1..

Node

:= [
    Element(Str, List({ name : Str, value : Str }), List(Node)),
    Text(Str),
]

An XML element or text node.

is_eq : _

Compare two XML nodes structurally.