pub struct XPath(_);
Expand description
A compiled XPath. Construct via Factory
.
Implementations§
source§impl XPath
impl XPath
sourcepub fn evaluate<'d, N>(
&self,
context: &Context<'d>,
node: N
) -> Result<Value<'d>, ExecutionError>where
N: Into<Node<'d>>,
pub fn evaluate<'d, N>(
&self,
context: &Context<'d>,
node: N
) -> Result<Value<'d>, ExecutionError>where
N: Into<Node<'d>>,
Evaluate this expression in the given context.
Examples
The most common case is to pass in a reference to a Context
:
extern crate sxd_document;
extern crate sxd_xpath;
use sxd_document::dom::Document;
use sxd_xpath::{XPath, Context};
fn my_evaluate(doc: Document, xpath: XPath) {
let mut context = Context::new();
let value = xpath.evaluate(&context, doc.root());
println!("The result was: {:?}", value);
}