A minimalist, self-contained ES6 HTML/XML parser based on htmlparser2
npm install htmlparser2-es6A minimalist ES6-compatible HTML/XML parser. A callback interface is provided.
A live demo of the original htmlparser2 is available here.
``javascript
var htmlparser = require("htmlparser2-es6");
var parser = new htmlparser({
onopentag: function(name, attribs){
if(name === "script" && attribs.type === "text/javascript"){
console.log("JS! Hooray!");
}
},
ontext: function(text){
console.log("-->", text);
},
onclosetag: function(tagname){
if(tagname === "script"){
console.log("That's it?!");
}
}
}, {decodeEntities: true});
parser.write("Xyz