xpathify
CSS selector to XPath 1.0 converter.
Rust
assert_eq!;
assert_eq!;
assert_eq!; // unsupported selector
Supported syntax
| CSS | XPath |
|---|---|
*, div, .class, #id |
//*, //div, class containment test, @id equality |
a b, a > b, a ~ b, a + b |
//, /, following-sibling::b, following-sibling::b[1] |
[attr], [attr=v] |
@attr, @attr="v" |
[attr^=v], [attr$=v], [attr*=v] |
starts-with, substring, contains |
[attr~=v], [attr|=v] |
word containment, v or v- prefix |
:root, :first-child, :last-child |
/, sibling absence tests |
:nth-child(n), :nth-of-type(n), :first-of-type, :last-of-type |
positional predicates |
:not(s) where s is one class, id, tag or attribute |
not(...) |
Anything else, including selector lists and a combinator inside :not(), returns the empty string.