pub struct Selection<'a> { /* private fields */ }Expand description
A collection of matched nodes from a selector query.
Provides iteration, text extraction, attribute access, and sub-selection (chaining).
Implementations§
Source§impl<'a> Selection<'a>
impl<'a> Selection<'a>
Sourcepub fn iter(&self) -> impl Iterator<Item = NodeRef<'a>> + '_
pub fn iter(&self) -> impl Iterator<Item = NodeRef<'a>> + '_
Iterate over matched nodes as NodeRef.
Sourcepub fn attr(&self, name: &str) -> Option<&'a str>
pub fn attr(&self, name: &str) -> Option<&'a str>
Get an attribute value from the first matched node.
Sourcepub fn inner_html(&self) -> String
pub fn inner_html(&self) -> String
Get inner HTML from the first matched node.
Sourcepub fn select_compiled(
&self,
sel: &CompiledSelector,
) -> Result<Selection<'a>, SelectorError>
pub fn select_compiled( &self, sel: &CompiledSelector, ) -> Result<Selection<'a>, SelectorError>
Sub-select with a pre-compiled selector within the matched nodes.
Each matched node is used as a subtree root, and results are deduplicated in document order.
Sourcepub fn select(&self, css: &str) -> Result<Selection<'a>, SelectorError>
pub fn select(&self, css: &str) -> Result<Selection<'a>, SelectorError>
Sub-select: run a CSS selector within the matched nodes.
Each matched node is used as a subtree root, and results are deduplicated in document order.
Sourcepub fn xpath(&self, expr: &str) -> Result<XPathResult, XPathError>
pub fn xpath(&self, expr: &str) -> Result<XPathResult, XPathError>
Evaluate an XPath expression within the matched nodes.
Each matched node is used as a context root, and results are deduplicated in document order.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Selection<'a>
impl<'a> RefUnwindSafe for Selection<'a>
impl<'a> Send for Selection<'a>
impl<'a> Sync for Selection<'a>
impl<'a> Unpin for Selection<'a>
impl<'a> UnsafeUnpin for Selection<'a>
impl<'a> UnwindSafe for Selection<'a>
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