Trait soup::NodeExt [−][src]
Adds some convenience methods to the html5ever::rcdom::Node
type
Required methods
Loading content...Provided methods
fn is_document(&self) -> bool
[src]
Returns true
if node is of type Document
fn is_doctype(&self) -> bool
[src]
Returns true
if node is of type Doctype
fn is_text(&self) -> bool
[src]
Returns true
if node is of type Text
fn is_comment(&self) -> bool
[src]
Returns true
if node is of type Comment
fn is_processing_instruction(&self) -> bool
[src]
Returns true
if node is of type ProcessingInstruction
fn is_element(&self) -> bool
[src]
Returns true
if node is of type Element
fn name(&self) -> &str
[src]
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]”
fn get(&self, attr: &str) -> Option<String>
[src]
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().expect("Couldn't find div"); assert_eq!(div.get("class"), Some("foo bar".to_string()));
fn attrs(&self) -> BTreeMap<String, String>
[src]
Returns the node’s attributes as a BTreeMap
fn text(&self) -> String
[src]
Retrieves the text value of this element, as well as it’s child elements
fn display(&self) -> String
[src]
Returns the node as an html tag
fn parent(&self) -> Option<Handle>
[src]
Navigates to the parent of the node, if there is one
Example
extern crate soup; use soup::prelude::*; let soup = Soup::new(r#"<div id=""><b>FOO</b></div>"#); let b = soup.tag("b").find().expect("Couldn't find tag 'b'"); let div = b.parent().expect("Couldn't get parent of tag 'b'"); assert_eq!(div.name(), "div".to_string());