You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

symbols-html-parser

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

symbols-html-parser

Parse HTML to Object

1.0.1
Source
npmnpm
Version published
Weekly downloads
1
-50%
Maintainers
1
Weekly downloads
 
Created
Source

HTML Parser

This is a simple HTML to Virtual Tree parser that can be used both in the CLI and the browser.

Usage

CLI Usage

To parse an HTML file using the command line interface (CLI), run the following command:

node main.js <html-file-path>

Node Js Installation

node main.js <html-file-path>

Browser Usage

To use the parser in the browser, follow these steps:

Include the html-to-vtree.js script in your HTML file:

<script src="html-to-vtree.js"></script> 

Create a textarea element where users can input HTML:

<script src="html-to-vtree.js"></script> 
const htmlString = '<div class="container">Hello, <b>world</b></div>';
const parser = new HtmlParser(htmlString);
const rootNode = parser.parseHtml();

// output 

{
    tag: 'div',
    text: 'Hello, ',
    class: 'container',
    children: [
        {tag: 'b', text: 'world'}
    ]
}

FAQs

Package last updated on 11 Sep 2023

Did you know?

Socket

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