# domhandler [![Build Status](https://travis-ci.com/fb55/domhandler.svg?branch=master)](https://travis-ci.com/fb55/domhandler) The DOM handler creates a tree containing all nodes of a page. The tree can be manipulated using the [domutils](https://github.com/fb55/domutils) or [cheerio](https://github.com/cheeriojs/cheerio) libraries and rendered using [dom-serializer](https://github.com/cheeriojs/dom-serializer) . ## Usage ```javascript const handler = new DomHandler([ callback(err, dom), ] [ options ]); // const parser = new Parser(handler[, options]); ``` Available options are described below. ## Example ```javascript const { Parser } = require("htmlparser2"); const { DomHandler } = require("domhandler"); const rawHtml = "Xyz "; const handler = new DomHandler((error, dom) => { if (error) { // Handle error } else { // Parsing completed, do something console.log(dom); } }); const parser = new Parser(handler); parser.write(rawHtml); parser.end(); ``` Output: ```javascript [ { data: "Xyz ", type: "text", }, { type: "script", name: "script", attribs: { language: "javascript", }, children: [ { data: "var foo = '';<", type: "text", }, ], }, { data: "