Package Exports
- dom-parser
- dom-parser/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (dom-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
dom-parser
Fast, tiny, zero-dependency DOM parser based on RegExps
Installation
npm install dom-parserUsage
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');
API
Dom
Implemented methods
- getElementById
- getElementsByClassName
- getElementsByTagName
- getElementsByName
Node
Implemented properties
- nodeType
- nodeName
- childNodes
- firstChild
- lastChild
- parentNode
- attributes
- innerHTML
- outerHTML
- textContent
Implemented methods
- getAttribute
- getElementById
- getElementsByClassName
- getElementsByTagName
- getElementsByName
Usage - https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
Contributing
Issues and pull requests are welcome!