xpath-reader

Current Version xpath-reader

Provides a convenient API to read from XML using XPath queries.

This crate is mostly a wrapper around the crate sxd_xpath.

Examples

```rust use xpath_reader::{Context, XpathReader, XpathStrReader};

let xml = r#""#;

let mut context = Context::new(); context.set_namespace("b", "books");

let reader = XpathStrReader::new(xml, &context).unwrap();

let name: String = reader.read("//@name").unwrap(); asserteq!(name, "Neuromancer".tostring());

let publisher: Option = reader.readoption("//@publisher").unwrap(); let author: Option = reader.readoption("//@author").unwrap(); asserteq!(publisher, None); asserteq!(author, Some("William Gibson".to_string()));

let tags: Vec = reader.readvec("//b:tags/b:tag/@name").unwrap(); asserteq!(tags, vec!["cyberpunk".tostring(), "sci-fi".tostring()]); ```