1.0.2 • Published 4 years ago

document-tree v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

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: []
//       }
//     ]
//   }
// ]