[][src]Struct nipper::Selection

pub struct Selection<'a> { /* fields omitted */ }

Selection represents a collection of nodes matching some criteria. The initial Selection object can be created by using [Document::select], and then manipulated using methods itself.

Implementations

impl<'a> Selection<'a>[src]

pub fn remove(&mut self)[src]

Removes the set of matched elements from the document.

pub fn set_html<T>(&mut self, html: T) where
    T: Into<StrTendril>, 
[src]

Set the html contents of each element in the selection to specified parsed HTML.

pub fn replace_with_html<T>(&mut self, html: T) where
    T: Into<StrTendril>, 
[src]

Replaces each element in the set of matched elements with the parsed HTML. It returns the removed elements.

This follows the same rules as append.

pub fn replace_with_selection(&mut self, sel: &Selection)[src]

Replaces each element in the set of matched element with the nodes from the given selection.

This follows the same rules as append.

pub fn append_html<T>(&mut self, html: T) where
    T: Into<StrTendril>, 
[src]

Parses the html and appends it to the set of matched elements.

pub fn append_selection(&mut self, sel: &Selection)[src]

Appends the elements in the selection to the end of each element in the set of matched elements.

impl<'a> Selection<'a>[src]

pub fn attr(&self, name: &str) -> Option<StrTendril>[src]

Gets the specified attribute's value for the first element in the selection. To get the value for each element individually, use a looping construct such as map method.

pub fn attr_or(&self, name: &str, default: &str) -> StrTendril[src]

Works like attr but returns default value if attribute is not present.

pub fn set_attr(&mut self, name: &str, val: &str)[src]

Sets the given attribute to each element in the set of matched elements.

pub fn remove_attr(&mut self, name: &str)[src]

Removes the named attribute from each element in the set of matched elements.

pub fn add_class(&mut self, class: &str)[src]

Adds the given class to each element in the set of matched elements. Multiple class names can be specified, separated by a space via multiple arguments.

pub fn has_class(&self, class: &str) -> bool[src]

Determines whether any of the matched elements are assigned the given class.

pub fn remove_class(&mut self, class: &str)[src]

Removes the given class from each element in the set of matched elements. Multiple class names can be specified, separated by a space via multiple arguments.

pub fn length(&self) -> usize[src]

Returns the number of elements in the selection object.

pub fn size(&self) -> usize[src]

Is an alias for length.

pub fn exists(&self) -> bool[src]

Is there any matched elements.

pub fn html(&self) -> StrTendril[src]

Gets the HTML contents of the first element in the set of matched elements. It includes the text and comment nodes.

pub fn text(&self) -> StrTendril[src]

Gets the combined text content of each element in the set of matched elements, including their descendants.

impl<'a> Selection<'a>[src]

pub fn is(&self, sel: &str) -> bool[src]

Checks the current matched set of elements against a selector and returns true if at least one of these elements matches.

pub fn is_matcher(&self, matcher: &Matcher) -> bool[src]

Checks the current matched set of elements against a matcher and returns true if at least one of these elements matches.

pub fn is_selection(&self, sel: &Selection) -> bool[src]

Checks the current matches set of elemets against a selection and returns true if at least one of these elements matches.

impl<'a> Selection<'a>[src]

pub fn select(&self, sel: &str) -> Selection<'a>[src]

Gets the descendants of each element in the current set of matched elements, filter by a selector. It returns a new Selection object containing these matched elements.

Panics

Panics if failed to parse the given CSS selector.

pub fn nip(&self, sel: &str) -> Selection<'a>[src]

Alias for select, it gets the descendants of each element in the current set of matched elements, filter by a selector. It returns a new Selection object containing these matched elements.

Panics

Panics if failed to parse the given CSS selector.

pub fn try_select(&self, sel: &str) -> Option<Selection<'a>>[src]

Gets the descendants of each element in the current set of matched elements, filter by a selector. It returns a new Selection object containing these matched elements.

pub fn select_matcher(&self, matcher: &Matcher) -> Selection<'a>[src]

Gets the descendants of each element in the current set of matched elements, filter by a matcher. It returns a new Selection object containing these matched elements.

pub fn nodes(&self) -> &[Node<'a>][src]

Returns a slice of underlying nodes.

pub fn iter(&self) -> Selections<Node<'a>>[src]

Creates an iterator over these matched elements.

pub fn parent(&self) -> Selection<'a>[src]

Gets the parent of each element in the selection. It returns a mew Selection object containing these elements.

pub fn children(&self) -> Selection<'a>[src]

Gets the child elements of each element in the selection. It returns a new Selection object containing these elements.

pub fn next(&self) -> Selection<'a>[src]

👎 Deprecated since 0.1.6:

Please use next_sibling

Gets the immediately following sibling of each element in the selection. It returns a new Selection object containing these elements.

pub fn next_sibling(&self) -> Selection<'a>[src]

Gets the immediately following sibling of each element in the selection. It returns a new Selection object containing these elements.

pub fn prev_sibling(&self) -> Selection<'a>[src]

Gets the immediately previous sibling of each element in the selection. It returns a new Selection object containing these elements.

pub fn first(&self) -> Selection<'a>[src]

Reduces the set of matched elements to the first in the set. It returns a new selection object, and an empty selection object if the selection is empty.

pub fn last(&self) -> Selection<'a>[src]

Reduces the set of matched elements to the last in the set. It returns a new selection object, and an empty selection object if the selection is empty.

pub fn get(&self, index: usize) -> Option<&Node<'a>>[src]

Retrieves the underlying node at the specified index.

Trait Implementations

impl<'a> Clone for Selection<'a>[src]

impl<'a> Debug for Selection<'a>[src]

impl<'a> Default for Selection<'a>[src]

Auto Trait Implementations

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> !UnwindSafe for Selection<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.