pub struct Html {
pub quirks_mode: QuirksMode,
pub tree: Tree<Node>,
pub lang: String,
}Expand description
An HTML tree.
Parsing does not fail hard. Instead, the quirks_mode is set and errors are added to the
errors field. The tree will still be populated as best as possible.
Implements the TreeSink trait from the html5ever crate, which allows HTML to be parsed.
Fields§
§quirks_mode: QuirksModeThe quirks mode.
tree: Tree<Node>The node tree.
lang: StringThe html language of the document.
Implementations§
Source§impl Html
impl Html
Sourcepub fn new_document() -> Self
pub fn new_document() -> Self
Creates an empty HTML document.
Sourcepub fn new_fragment() -> Self
pub fn new_fragment() -> Self
Creates an empty HTML fragment.
Sourcepub fn parse_document(document: &str) -> Self
pub fn parse_document(document: &str) -> Self
Parses a string of HTML as a document.
This is a convenience method for the following:
use html5ever::driver::{self, ParseOpts};
use scraper::Html;
use tendril::TendrilSink;
let parser = driver::parse_document(Html::new_document(), ParseOpts::default());
let html = parser.one(document);Sourcepub fn parse_fragment(fragment: &str) -> Self
pub fn parse_fragment(fragment: &str) -> Self
Parses a string of HTML as a fragment.
Sourcepub fn select<'a, 'b>(&'a self, selector: &'b Selector) -> Select<'a, 'b> ⓘ
pub fn select<'a, 'b>(&'a self, selector: &'b Selector) -> Select<'a, 'b> ⓘ
Returns an iterator over elements matching a selector.
Sourcepub fn root_element(&self) -> ElementRef<'_>
pub fn root_element(&self) -> ElementRef<'_>
Returns the root <html> element.
Sourcepub fn set_language(&mut self, lang: String)
pub fn set_language(&mut self, lang: String)
Set the html language of the document by getting the lang attr
Sourcepub fn remove_node(&mut self, node_id: NodeId)
pub fn remove_node(&mut self, node_id: NodeId)
Find and remove a node
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Html
impl !RefUnwindSafe for Html
impl Send for Html
impl !Sync for Html
impl Unpin for Html
impl UnsafeUnpin for Html
impl UnwindSafe for Html
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more