I’ve been trying to query XML with the sxd_xpath crate and I can’t seem to figure out how to handle a nodeset
let package = parser::parse("<feed><title>hest</title><title>hest2</title><title>hest3</title><title>hest4</title></feed>").expect("failed to parse XML"); let document = package.as_document(); let factory = Factory::new(); let xpath = factory.build("/feed/title").expect("Could not compile XPath"); let xpath = xpath.expect("No XPath was compiled"); let context = Context::new(); let value = xpath.evaluate(&context, document.root()).expect("XPath evaluation failed");
I would like to iterate over every node and print out the value of
<title>. But I do not understand how to do it.
I’m fairly new in the Rust world, but are comming from C# and Python and this is a experiment to port a Python project to Rust.