pub struct Element<'doc, 'src> { /* private fields */ }Expand description
A borrowed view of an element in a Document.
Implementations§
Source§impl<'doc, 'src> Element<'doc, 'src>
impl<'doc, 'src> Element<'doc, 'src>
Sourcepub fn is(self, name: &str) -> bool
pub fn is(self, name: &str) -> bool
Compare an HTML element name without ASCII case sensitivity.
Sourcepub fn attribute(self, name: &str) -> Option<&'doc Attribute<'src>>
pub fn attribute(self, name: &str) -> Option<&'doc Attribute<'src>>
Find an attribute without ASCII case sensitivity. The first occurrence wins.
Values are already decoded; Attribute::raw_value preserves their
source spelling.
Sourcepub fn has_attribute(self, name: &str) -> bool
pub fn has_attribute(self, name: &str) -> bool
Test for an attribute, including a boolean attribute with no value.
Sourcepub fn attributes(self) -> impl Iterator<Item = &'doc Attribute<'src>>
pub fn attributes(self) -> impl Iterator<Item = &'doc Attribute<'src>>
Iterate over the element’s attributes in source order, without duplicates.
Sourcepub fn parent(self) -> Option<Self>
pub fn parent(self) -> Option<Self>
Return the containing lexical element, or None for a root element.
Sourcepub fn descendants(self) -> impl Iterator<Item = Self>
pub fn descendants(self) -> impl Iterator<Item = Self>
Iterate over descendant elements, excluding this element, in source order.
Sourcepub fn children(self) -> impl Iterator<Item = Self>
pub fn children(self) -> impl Iterator<Item = Self>
Iterate over direct child elements in source order.
Sourcepub fn text(self) -> Cow<'doc, str>
pub fn text(self) -> Cow<'doc, str>
Concatenate descendant text in source order, excluding comments and declarations.
Character references are decoded according to the tokenizer state and remain literal in script/style contents. No layout whitespace is inserted. A single segment borrows from the document; multiple segments allocate. With no text, this returns a borrowed empty string.