@federicocarboni/saxe
    Preparing search index...

    Class SaxParser

    A streaming SAX-style XML parser.

    SaxParser processes input incrementally, notifying the provided SaxHandler of parsing events such as start tags, end tags and text content. Because the parser does not construct a tree representation of the document it is possible to process very large inputs efficiently.

    Malformed XML documents are not accepted, parsing errors cannot be recovered from.

    For namespace-aware processing use SaxNamespaceParser instead.

    const parser = new SaxParser({
    startTag(name, attributes) {
    // Start tag: example
    // Start tag: empty-tag [attr, value]
    console.log("Start tag:", name, ...attributes);
    },
    endTag(name) {
    // End tag: example
    // End tag: empty-tag
    console.log("End tag:", name);
    },
    text(content) {
    // Text: Hello, world!
    console.log("Text:", content);
    },
    });
    parser.parse("<example>Hello, world!", {stream: true});
    parser.parse(`<empty-tag attr="value" />`, {stream: true});
    parser.parse("</example>");

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Parses XML from input and notifies the handler of parsing events such as start tags, end tags and text content.

      Parameters

      • input: string | undefined = undefined

        A string containing the XML data to parse.

      • options: SaxParseOptions | undefined = undefined

      Returns void

      SaxError