XML Tree Parser for Scriptable

This is inspired by the familiar DOMParser interface from browsers but builds the equivalent functionality on top of XMLParser instead. It builds a tree of elements and text nodes, exactly representing the contents of the XML document, with one function call.

parseXML(`<xml document="here">`);

The API is considerably simpler than DOMParser, using basic JavaScript types and a single small class to represent elements. Not all features of DOMParser are supported, but this is a minimum feature set intended for reading XML documents quickly. Functions are also provided to find elements in a parsed tree.

3 Likes