pub struct VDom<'a, const MAX_NODES: usize = 0, const MAX_STACK: usize = 0, const MAX_ROOTS: usize = 0, const MAX_IDS: usize = 0, const MAX_CLASSES: usize = 0, const MAX_SELECTOR_NODES: usize = 0> { /* private fields */ }Expand description
VDom represents a Document Object Model
It is the result of parsing an HTML document.
Internally it is only a wrapper around the Parser struct, in which all of the HTML tags are stored.
Many functions of the public API take a reference to a Parser as a parameter to resolve NodeHandles to Nodes.
Implementations§
Source§impl<'a, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize> VDom<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>
impl<'a, const MAX_NODES: usize, const MAX_STACK: usize, const MAX_ROOTS: usize, const MAX_IDS: usize, const MAX_CLASSES: usize, const MAX_SELECTOR_NODES: usize> VDom<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>
Sourcepub fn parser(
&self,
) -> &Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>
pub fn parser( &self, ) -> &Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>
Returns a reference to the underlying parser
Sourcepub fn parser_mut(
&mut self,
) -> &mut Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>
pub fn parser_mut( &mut self, ) -> &mut Parser<'a, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>
Returns a mutable reference to the underlying parser
Sourcepub fn get_element_by_id<'b, S>(&'b self, id: S) -> Option<NodeHandle>
pub fn get_element_by_id<'b, S>(&'b self, id: S) -> Option<NodeHandle>
Finds an element by its id attribute.
Sourcepub fn nodes(&self) -> &[Node<'a>]
pub fn nodes(&self) -> &[Node<'a>]
Returns a slice of all the elements in the HTML document
The difference between children() and nodes() is that children only returns the immediate children of the root node,
while nodes() returns all nodes, including nested tags.
§Order
The order of the returned nodes is the same as the order of the nodes in the HTML document.
Sourcepub fn nodes_mut(&mut self) -> &mut [Node<'a>]
pub fn nodes_mut(&mut self) -> &mut [Node<'a>]
Returns a mutable slice of all the elements in the HTML document
The difference between children() and nodes() is that children only returns the immediate children of the root node,
while nodes() returns all nodes, including nested tags.
Sourcepub fn children(&self) -> &[NodeHandle]
pub fn children(&self) -> &[NodeHandle]
Returns the topmost subnodes (“children”) of this DOM
Sourcepub fn children_mut(&mut self) -> &mut [NodeHandle]
pub fn children_mut(&mut self) -> &mut [NodeHandle]
Returns a mutable reference to the topmost subnodes (“children”) of this DOM
Sourcepub fn version(&self) -> Option<HTMLVersion>
pub fn version(&self) -> Option<HTMLVersion>
Returns the HTML version.
This is determined by the <!DOCTYPE> tag
Sourcepub fn write_outer_html<W: Write>(&self, dest: &mut W) -> Result
pub fn write_outer_html<W: Write>(&self, dest: &mut W) -> Result
Writes the contained markup of all root elements without allocating.
Sourcepub fn query_selector<'b>(
&'b self,
selector: &'b str,
) -> Result<QuerySelectorIterator<'a, 'b, Self, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>, ParseError>
pub fn query_selector<'b>( &'b self, selector: &'b str, ) -> Result<QuerySelectorIterator<'a, 'b, Self, MAX_NODES, MAX_STACK, MAX_ROOTS, MAX_IDS, MAX_CLASSES, MAX_SELECTOR_NODES>, ParseError>
Tries to parse the query selector and returns an iterator over matching elements.