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
std/xml/errorXmlError: what went wrong reading XML - text that is not well-formed, a name that breaks the rules of namespaces, an entity that is external or recursive, or an expansion pastXml.entityLimit.std/xml/nodeThe tree of an XML document, [XmlNode], with the pieces it is made of: a qualified name, an attribute and the XML declaration.std/xml/xml[Xml], the format: a value with the options of XML, which reads a document into the tree of [XmlNode]s and writes that tree back.
Everything
- type
XmlXML, with its options. - type
XmlAttributeOne attribute of an element, in the order the document wrote it. - type
XmlDeclarationWhat the XML declaration at the start of a document says:<?xml version="1.0" encoding="UTF-8"?>. - type
XmlErrorWhy a text is not an XML document this reader accepts, and where. - type
XmlNameA name in the sense of Namespaces in XML: the local part, the prefix it was written with and the namespace the prefix stood for where it was read. - type
XmlNodeOne node of an XML document, as a tree: the document, an element, a run of text, a CDATA section, a comment, a processing instruction or the document type declaration.