according to the docs it seems you can chain predicates, so try below:
use predicate::Predicate;
let pred = predicate::Class("p-org")
.child(predicate::Name("div"))
.child(predicate::Text);
let mut matches = document.find(pred);
let node = matches.next()
.expect("Failed to find matching node");
let info = node.as_text()
.expect("Matching node is not a text node");
println!("{}", info);
It seems like lots of beginners have issues with invoking methods that are imported with a trait. Maybe this section of The Book should be expanded. It’s not the most obvious concept. I definitely remember having trouble with it at first.
Why I can't extract the information directly form Some(Element { name: "span", attrs: [("class", "p-org")], children: [Element { name: "div", attrs: [], children: [Text("University of California, Santa Cruz")] }] })
You can, but I thought it's better to build more accurate selector to match the target text node directly.
predicate intended to be select::predicate module. You can either prepend select:: path to them same as you did for predicate::Predicate, or add use select::predicate at the top to import its name into local scope.