pub struct DomTree { /* private fields */ }Expand description
Tree representation of html (DOM).
Will panic if invalid or removed id’s are used.
Implementations§
Source§impl DomTree
impl DomTree
pub fn new() -> DomTree
pub fn head(&self) -> DomId
pub fn body(&self) -> DomId
pub fn get_mut(&mut self, id: DomId) -> &mut DomNode
Sourcepub fn get_elements_by_tag_name(
&self,
tag_name: impl Into<String>,
) -> Vec<DomId> ⓘ
pub fn get_elements_by_tag_name( &self, tag_name: impl Into<String>, ) -> Vec<DomId> ⓘ
Get all elements with a certain html tag
Sourcepub fn add_html(&mut self, parent_id: DomId, html: Html) -> Option<usize>
pub fn add_html(&mut self, parent_id: DomId, html: Html) -> Option<usize>
Add parsed html to tree
Sourcepub fn add(&mut self, parent_id: DomId, kind: DomNodeKind) -> usize
pub fn add(&mut self, parent_id: DomId, kind: DomNodeKind) -> usize
Add a node to the tree return the id (index) of the node
Sourcepub fn add_element(&mut self, parent_id: DomId, tag: impl Into<String>) -> usize
pub fn add_element(&mut self, parent_id: DomId, tag: impl Into<String>) -> usize
Add a node to the tree return the id (index) of the node
pub fn add_element_with_attributes( &mut self, parent_id: DomId, tag: impl Into<String>, attributes: HashMap<String, String>, ) -> DomId
Sourcepub fn add_text(&mut self, parent_id: DomId, text: impl Into<String>) -> usize
pub fn add_text(&mut self, parent_id: DomId, text: impl Into<String>) -> usize
Add a node to the tree return the id (index) of the node
Sourcepub fn set_parent(&mut self, id: DomId, new_parent: DomId)
pub fn set_parent(&mut self, id: DomId, new_parent: DomId)
set a new parent for a node
pub fn to_html_string(self) -> String
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DomTree
impl RefUnwindSafe for DomTree
impl Send for DomTree
impl Sync for DomTree
impl Unpin for DomTree
impl UnwindSafe for DomTree
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