cloudflare / cloudflare/lol-html

How to extract inner HTML of an element?

Open
#212 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.1k
Forks
111
PR merge metrics
No merged PRs in 30d

Description

Hello!

I'm trying to use lol_html as an HTML parser to extract all content within an element, it's inner HTML. However I haven't figured out the right methods for this yet. Here is what I want to do, given the following HTML snippet:

```


foo


```

I want to extract all the content within the element matching css selector `article#main-content` and store it in a String named `content` after this runs the value of `content` will be equal to:

```


foo



```

I've what would be perfect would be a method on the element called `get_inner_content()` there seems to be all the methods for manipulating the inner content but not actually getting it such as:
`set_inner_content`
`remove_and_keep_content`

Maybe I'm thinking about this wrong, any help just getting the inner content of an element would be so hepful!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.