std/xml

XML 1.0 (fifth edition) with Namespaces in XML 1.0 as a format, written in TorbScript: Xml reads a document into a tree of XmlNodes and writes that tree back.

const tree = Xml().parse(text)?
print tree.root()?.child("Name")?.text()

The tree is the model. XML is a document format and not a data model: an element has attributes, ordered mixed content and a namespace, none of which fits a record, so there is no encode and decode here and no trait of its own either. The tree is a plain type; build a value from it with the methods of XmlNode.

Names are resolved. An XmlName holds the local name, the prefix it was written with and the namespace it stands for, and XmlName.isNamed compares by local name and namespace.

Safe by construction. The reader never fetches or opens anything: an external entity is recorded and an error where it is used, and an external subset is not read. It reads the internal subset of a document type declaration and expands the entities that declares, and cuts an expansion off at Xml.entityLimit characters, which is where entity expansion attacks live. The default values of its attribute lists are applied.

Modules

Everything