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§
fn get_node(&self) -> &Node
fn get_handle(self) -> Handle
Provided Methods§
sourcefn name(&self) -> &str
fn name(&self) -> &str
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]”
sourcefn get(&self, attr: &str) -> Option<String>
fn get(&self, attr: &str) -> Option<String>
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()));