Skip to content

xml

A global table of functions: xml.<function>(…).

decode

xml.decode: (text: string) -> XmlElement

Reads XML text into an element: its name, attrs (by name), order (the attribute names as written), children, text and line. Raises an error with the line when the text is not well-formed.

load

xml.load: (path: string) -> (XmlElement?, string?)

Reads an XML file into the element xml.decode gives, or returns nil and a message (not found, not allowed, not well-formed). It reads a file in a shipped pack as well, where authored XML and definitions are cooked in place and fs.read_text would give binary.

encode

xml.encode: (element: XmlElement) -> string

Writes an element as XML text, with two spaces of indent. Attributes come in the order of order, then the rest sorted by name.