#[test]
fn xpath_started_with_root_element() {
let text = r#"
<ul>
<li>Foo</li>
<li>Bar</li>
<li>Baz</li>
</ul>
"#;
let document = html::parse(&text).unwrap();
let xpath = xpath::parse("//ul/li[1]").unwrap();
let results = xpath.apply(&document).unwrap();
let el = results[0].get_text(&document);
assert_eq!(el.unwrap(), "Foo");
}
I have HTML:
If i try to use find this xpath
//ul/li
- i have an error:The reason here is that ul - is a root element in html. If i use this html all should be fine:
The code for reproduce: