Trait soup::NodeExt

source ·
pub trait NodeExt: Sized {
    fn get_node(&self) -> &Node;
    fn get_handle(self) -> Handle;

    fn name(&self) -> &str { ... }
    fn get(&self, attr: &str) -> Option<String> { ... }
    fn attrs(&self) -> BTreeMap<String, String> { ... }
    fn text(&self) -> Option<String> { ... }
    fn limit(self, limit: usize) -> QueryBuilder { ... }
    fn tag(self, tag: &str) -> QueryBuilder { ... }
    fn attr(self, name: &str, value: &str) -> QueryBuilder { ... }
    fn class(self, value: &str) -> QueryBuilder { ... }
    fn display(&self) -> String { ... }
}
Expand description

Adds some convenience methods to the html5ever::rcdom::Node type

Required Methods§

Provided Methods§

Retrieves the name of the node

If this node is an element, the name of that element is returned. Otherwise, special names are used:

Document -> “[document]” Doctype -> “[doctype]” Text -> “[text]” Comment -> “[comment]” ProcessingInstruction -> “[processing-instruction]”

Looks for an attribute named attr and returns it’s value as a string

Example
let soup = Soup::new(r#"<div class="foo bar"></div>"#);
let div = soup.tag("div").find().unwrap();
assert_eq!(div.get("class"), Some("foo bar".to_string()));

Returns the node’s attributes as a BTreeMap

Retrieves the text value of this element, as well as it’s child elements

Starts building a Query, with limit limit

Starts building a Query, with tag tag

Starts building a Query, with attr attr

Starts building a Query, with class class

Returns the node as an html tag

Implementations on Foreign Types§

Implementors§