tl is an efficient and easy to use HTML parser written in Rust.
It does minimal to no copying during parsing by borrowing parts of the input string.
Additionally, it keeps track of parsed elements and stores elements with an id
attribute
in an internal HashMap, which makes get_element_by_id
as well as get_elements_by_class_name
very fast.
Finding an element by its id
attribute and printing the inner text:
```rust
fn main() {
let input = r#"
Hello
"#; let dom = tl::parse(input); let element = dom.getelementby_id("text").expect("Failed to find element");println!("Inner text: {}", element.inner_text());
} ```
Add tl
to your dependencies.
toml
[dependencies]
tl = "0.1.0"