tinymce.html.SaxParser

This class parses HTML code using pure JavaScript and executes various events for each item it finds. It will always execute the events in the right order for tag soup code like <b><p></b></p>. It will also remove elements and attributes that doesn’t fit the schema if the validate setting is enabled.

Examples

var parser = new tinymce.html.SaxParser({
    validate: true,

    comment: function(text) {
        console.log('Comment:', text);
    },

    cdata: function(text) {
        console.log('CDATA:', text);
    },

    text: function(text, raw) {
        console.log('Text:', text, 'Raw:', raw);
    },

    start: function(name, attrs, empty) {
        console.log('Start:', name, attrs, empty);
    },

    end: function(name) {
        console.log('End:', name);
    },

    pi: function(name, text) {
        console.log('PI:', name, text);
    },

    doctype: function(text) {
        console.log('DocType:', text);
    }
}, schema);

Summary

Constructors

Name Summary Defined by

SaxParser()

Constructs a new SaxParser instance.

SaxParser

Methods

Name Summary Defined by

parse()

Parses the specified HTML string and executes the callbacks for each item it finds.

SaxParser

Constructors

SaxParser

public constructor function SaxParser(settings: Object, schema: tinymce.html.Schema)

Constructs a new SaxParser instance.

Parameters

  • settings (Object) - Name/value collection of settings. comment, cdata, text, start and end are callbacks.

  • schema (Schema) - HTML Schema class to use when parsing.

Methods

parse()

parse(html: String)

Parses the specified HTML string and executes the callbacks for each item it finds.

Examples

SaxParser({...}).parse('<b>text</b>');

Parameters

  • html (String) - Html string to sax parse.