Socket
Socket
Sign inDemoInstall

dom-parser

Package Overview
Dependencies
0
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dom-parser

Fast dom parser based on regexps


Version published
Weekly downloads
30K
decreased by-19.18%
Maintainers
1
Install size
14.7 kB
Created
Weekly downloads
 

Readme

Source

dom-parser

Fast, tiny, zero-dependency DOM parser based on RegExps

GitHub Workflow Status (with event) Jest coverage npm GitHub

Installation

npm install dom-parser

Usage

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!

Keywords

FAQs

Last updated on 12 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc