pub struct Element {
pub tag_name: String,
pub attributes: Vec<Attribute>,
pub children: Vec<Node>,
}Expand description
An HTML element.
Fields§
§tag_name: StringThe tag name (lowercase).
attributes: Vec<Attribute>The element’s attributes.
children: Vec<Node>The element’s child nodes.
Implementations§
Source§impl Element
impl Element
Sourcepub fn get_attribute(&self, name: &str) -> Option<&str>
pub fn get_attribute(&self, name: &str) -> Option<&str>
Get an attribute value by name.
Sourcepub fn has_attribute(&self, name: &str) -> bool
pub fn has_attribute(&self, name: &str) -> bool
Check if the element has an attribute.
Sourcepub fn set_attribute(
&mut self,
name: impl Into<String>,
value: impl Into<String>,
)
pub fn set_attribute( &mut self, name: impl Into<String>, value: impl Into<String>, )
Set an attribute value.
Sourcepub fn text_content(&self) -> Option<Cow<'_, str>>
pub fn text_content(&self) -> Option<Cow<'_, str>>
Get the text content of this element and its descendants.
Sourcepub fn find_element(&self, tag_name: &str) -> Option<&Self>
pub fn find_element(&self, tag_name: &str) -> Option<&Self>
Find the first descendant element with the given tag name.
Sourcepub fn find_all_elements(&self, tag_name: &str) -> Vec<&Self>
pub fn find_all_elements(&self, tag_name: &str) -> Vec<&Self>
Find all descendant elements with the given tag name.
Sourcepub fn find_by_class(&self, class_name: &str) -> Vec<&Self>
pub fn find_by_class(&self, class_name: &str) -> Vec<&Self>
Find elements by class name.
Sourcepub fn find_by_id(&self, id: &str) -> Option<&Self>
pub fn find_by_id(&self, id: &str) -> Option<&Self>
Find element by id.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Element
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnwindSafe for Element
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