pub struct Element { /* private fields */ }
Implementations
sourceimpl Element
impl Element
sourcepub fn tag(&self) -> Option<String>
pub fn tag(&self) -> Option<String>
Get tag value
Example
use crabquery::Document;
let doc = Document::from("<a class='link'>hi there</a>");
let sel = doc.select("a");
let el = sel.first().unwrap();
assert_eq!(el.tag().unwrap(), "a");
sourcepub fn text(&self) -> Option<String>
pub fn text(&self) -> Option<String>
Get text
Example
use crabquery::Document;
let doc = Document::from("<a class='link'>hi there</a>");
let sel = doc.select("a");
let el = sel.first().unwrap();
assert_eq!(el.text().unwrap(), "hi there");
sourcepub fn children(&self) -> Vec<Element>
pub fn children(&self) -> Vec<Element>
Get children elements
Example
use crabquery::Document;
let doc = Document::from("<a class='link'><span>hi there</span></a>");
let sel = doc.select("a");
let el = sel.first().unwrap();
assert_eq!(el.children().first().unwrap().text().unwrap(), "hi there");
sourcepub fn parent(&self) -> Option<Element>
pub fn parent(&self) -> Option<Element>
Get parent element
Example
use crabquery::Document;
let doc = Document::from("<a class='link'><span>hi there</span></a>");
let sel = doc.select("span");
let el = sel.first().unwrap();
assert_eq!(el.parent().unwrap().tag().unwrap(), "a");
sourcepub fn select(&self, selector: &str) -> Vec<Element>
pub fn select(&self, selector: &str) -> Vec<Element>
Select child elements using given css selector
Example
use crabquery::Document;
let doc = Document::from("<span><a class='link'>hi there</a></span>");
let sel = doc.select("span");
let el = sel.first().unwrap();
let sel = el.select("a");
let a = sel.first().unwrap();
assert_eq!(a.attr("class").unwrap(), "link");
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Element
impl !Send for Element
impl !Sync for Element
impl Unpin for Element
impl !UnwindSafe for Element
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more