Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

DOMParser is not defined

const htmlparser = require("htmlparser2");
const parser = new htmlparser.Parser({
  onopentag: (name, attrib) => {
    if (name=='p') console.log('a paragraph element is opening');
  }
}, {decodeEntities: true});
parser.write(`<!DOCTYPE html><p>Hello world</p>`);
parser.end();
// console output: 'a paragraph element is opening'
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #DOMParser #defined
ADD COMMENT
Topic
Name
3+4 =