Fast, tiny, zero-dependency DOM parser based on RegExps
npm install dom-parser
import { parseFromString } from 'dom-parser';
const html = await fs.readFileAsync('htmlToParse.html');
// Getting DOM model
const dom = parseFromString(html);
// Searching Nodes
const rootNode = dom.getElementById('rootNode');
const childNodes = rootNode.getElementsByClassName('childNodeClass');
- getElementById
- getElementsByClassName
- getElementsByTagName
- getElementsByName
- nodeType
- nodeName
- childNodes
- firstChild
- lastChild
- parentNode
- attributes
- innerHTML
- outerHTML
- textContent
- getAttribute
- getElementById
- getElementsByClassName
- getElementsByTagName
- getElementsByName
Usage - https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
Issues and pull requests are welcome!