Skip to content

How to extract inner HTML of an element? #212

@Jared-Sprague

Description

@Jared-Sprague

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:

<article id="main-content">
  <div>
    <p>foo</p>
  </div>
</article>

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:

  <div>
    <p>foo</p>
  </div>

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions