document-tree
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

document-tree

Generate document tree from your HTML/JSX

Installation

Use npm or yarn to install document-tree.

npm install document-tree --save

or

yarn add document-tree

Usage

const documentTree = require('document-tree').default; 

const htmlString = `
  <div id="testId">
    <div class="testClass"></div>
  </div>
`;

const tree = documentTree.generate(htmlString);

// tree = [
//   {
//     tagName: 'div',
//     attributes: {
//       id: 'testId'
//     },
//     children: [
//       {
//         tagName: 'div',
//         attributes: {
//           class: 'testClass'
//         },
//         children: []
//       }
//     ]
//   }
// ]

Package Sidebar

Install

npm i document-tree

Weekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

4.42 kB

Total Files

7

Last publish

Collaborators

  • sachinb94