domparser

Crates.iodomparser
lib.rsdomparser
version0.0.7
created_at2025-12-22 04:10:42.246027+00
updated_at2025-12-26 03:55:06.838505+00
descriptionA super fast html parser and manipulator written in rust.
homepage
repositoryhttps://github.com/utooland/domparser-rs
max_upload_size
id1999024
size67,998
(xusd320)

documentation

README

domparser

A super fast html parser and manipulator written in rust.

Installation

Add this to your Cargo.toml:

[dependencies]
domparser = "0.0.5"

Usage

use domparser::parse;

fn main() {
    let html = r#"<div id="foo" class="bar">hello <span>world</span></div>"#;
    let root = parse(html.to_string());

    let div = root.select("div".to_string()).unwrap();
    println!("{}", div.get_attribute("id".to_string()).unwrap()); // "foo"
    println!("{}", div.text()); // "hello world"
    
    div.set_attribute("title".to_string(), "my-title".to_string());
    println!("{}", div.outer_html()); 
    // <div id="foo" class="bar" title="my-title">hello <span>world</span></div>
}

Features

  • Parse HTML string to DOM
  • Select nodes with CSS selectors
  • Manipulate attributes and text
  • Serialize DOM back to HTML
Commit count: 0

cargo fmt