# xpathify
CSS selector to XPath 1.0 converter.
## Rust
```sh
cargo add xpathify
```
```rust
assert_eq!(xpathify::xpathify("div.item"), "//div[contains(concat(' ',normalize-space(@class),' '),' item ')]");
assert_eq!(xpathify::xpathify(":root > body"), "/body");
assert_eq!(xpathify::xpathify("div,span"), ""); // unsupported selector
```
## Supported syntax
| `*`, `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.