# xpath-to-css

> Utility function for converting XPath expressions to CSS selectors

Latest version **1.2.0** (published 2024-07-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install xpath-to-css
pnpm add xpath-to-css
yarn add xpath-to-css
bun add xpath-to-css
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2024-07-13 |
| First published | 2015-11-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 0 |
| Unpacked size | 10.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 32 |
| Author | Jonathan Svenheden |
| Maintainers | jonathanp |

## Links

- npm: https://www.npmjs.com/package/xpath-to-css
- Repository: https://github.com/svenheden/xpath-to-css
- Homepage: https://github.com/svenheden/xpath-to-css#readme
- Issues: https://github.com/svenheden/xpath-to-css/issues
- npm.io page: https://npm.io/package/xpath-to-css

## Recent versions

- 1.2.0 (latest) — 2024-07-13
- 1.1.0 — 2021-12-20
- 1.0.5 — 2020-05-11
- 1.0.4 — 2019-07-29
- 1.0.3 — 2018-11-05
- 1.0.2 — 2015-11-27
- 1.0.1 — 2015-11-27
- 1.0.0 — 2015-11-27

## README

# XPath to CSS

![Tests][tests-badge]
[![NPM version][npm-image]][npm-url]

Utility function for converting XPath expressions to CSS selectors.

Originally written in Python by [santiycr](https://github.com/santiycr) for [cssify](https://github.com/santiycr/cssify) and ported to JavaScript by [Dither](https://github.com/Dither) who published it in [this gist](https://gist.github.com/Dither/1909679). Since I needed it in a project and can't depend on a gist in my `package.json` I have converted it to ES2015 and CommonJS, cleaned it up a bit and [published it to npm][npm-url].

## Install

```
$ npm install --save xpath-to-css
```

## Usage

```js
import xPathToCss from "xpath-to-css";

const xPath =
  '//div[@id="foo"][2]/span[@class="bar"]//a[contains(@class, "baz")]//img[1]';
const css = xPathToCss(xPath);
console.log(css); // => 'div#foo:nth-of-type(2) > span.bar a[class*=baz] img:first-of-type'
```

## License

MIT © [Jonathan Svenheden](https://github.com/svenheden)

[npm-url]: https://npmjs.org/package/xpath-to-css
[npm-image]: https://badge.fury.io/js/xpath-to-css.svg
[tests-badge]: https://github.com/svenheden/xpath-to-css/workflows/Tests/badge.svg

---
_Source: https://npm.io/package/xpath-to-css · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
