document-tree
v1.0.2
Published
Generate document tree from your HTML/JSX
Downloads
8
Maintainers
Readme
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: []
// }
// ]
// }
// ]