Trait soup::NodeExt

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

    fn name(&self) -> &str { ... }
    fn get(&self, attr: &str) -> Option<String> { ... }
    fn attrs(&self) -> BTreeMap<String, String> { ... }
    fn text(&self) -> Option<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.find().tag("div").execute()?.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

Implementations on Foreign Types§

Implementors§