0.2.8
A super fast Node.js addon for HTML parsing and manipulation, written in Rust.
yarn add niddle # or npm install niddle
const { parse } = require('niddle'); const html = '<div id="main"><span>Hello</span></div>'; const root = parse(html); const mainDiv = root.select('#main'); mainDiv.append('<p>World</p>'); console.log(mainDiv.outerHtml()); // <div id="main"><span>Hello</span><p>World</p></div>
parse(html: string): NodeRepr
Parses an HTML string and returns a NodeRepr instance representing the root node.
NodeRepr
html
Represents a DOM node and provides various manipulation methods.
const { parse } = require('niddle'); const root = parse('<div id="foo" class="bar">hello <span>world</span></div>'); const div = root.select('div'); console.log(div.getAttribute('id')); // "foo" console.log(div.text()); // "hello world" div.setAttribute('title', 'my-title'); console.log(div.outerHtml()); // <div id="foo" class="bar" title="my-title">hello <span>world</span></div>
yarn install yarn build yarn test
cargo benchmark yarn benchmark
For more usage examples and advanced API, see the source code and benchmarks in the repository.
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
niddle
A super fast Node.js addon for HTML parsing and manipulation, written in Rust.
Features
Installation
Usage
API Documentation
parse(html: string): NodeReprParses an HTML string and returns a
NodeReprinstance representing the root node.Parameters
html(string): The HTML content to parse.Returns
NodeRepr: The parsed root node.NodeReprClassRepresents a DOM node and provides various manipulation methods.
Methods
Example
Contributing
Benchmark
For more usage examples and advanced API, see the source code and benchmarks in the repository.