pub fn cssifier<S: AsRef<str>>(xpath: S) -> Option<String>Expand description
Convert the Xpath selectors to CSS selector
§Things it supports
Any tag (including *), contains(), text(), indexed, any attribute (@id, @class, @anything).
§Things it does not support
Move up to a parent tag (//a/../p) and maybe something else I’m not aware of…
§Examples
Basic usage:
let result = cssifier::cssifier("//a/p");
assert_eq!(result, Some("a p".to_string()));
let result = cssifier::cssifier("//a/p[@id='hello']");
assert_eq!(result, Some("a p#hello".to_string()));
let result = cssifier::cssifier("//a/p[contains(text(), 'hello')]");
assert_eq!(result, Some("a p:contains(hello)".to_string()));
let result = cssifier::cssifier("*random selector//*"); // Invalid selectors throw a empty string (WIP)
assert_eq!(result, Some("".to_string()));