# css-to-xpath

> Converts CSS selectors to xpaths

Latest version **0.1.0** (published 2015-10-22) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2015-10-22 |
| First published | 2014-01-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 44 |
| Author | Josh Chisholm |
| Maintainers | joshski |
| Keywords | xpath, html, dsl |

## Links

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

## Dependencies (2)

- [bo-selector](https://npm.io/package/bo-selector.md) 0.0.10
- [xpath-builder](https://npm.io/package/xpath-builder.md) 0.0.7

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2015-10-22
- 0.0.3 — 2014-11-25
- 0.0.2 — 2014-11-25
- 0.0.1 — 2014-01-02

## README

# css-to-xpath

Converts [CSS3 selectors](http://www.w3.org/TR/css3-selectors/#selectors) to their XPath equivalents.

[![Build Status](https://secure.travis-ci.org/featurist/css-to-xpath.png?branch=master)](http://travis-ci.org/featurist/css-to-xpath)

### Usage

```js
var cssToXPath = require('css-to-xpath');

cssToXPath('p:not(:has(a.x))');
```
...returns the string:
```
.//p[not(.//a[contains(concat(' ', normalize-space(./@class), ' '), ' x ')])]
```

Or if you want to continue building the XPath with xpath-builder:
```js
var cssToXPath = require('css-to-xpath');

var xpathBuilderObject = cssToXPath.parse('p:not(:has(a.x))');
xpathBuilderObject = xpathBuilderObject.where(cssToXPath.xPathBuilder.text().equals('Some Text Content'));

// And get the XPath string
xpathBuilderObject.toXPath();
```

### How?

css-to-xpath parses css selectors using [bo-selector](https://github.com/featurist/bo-selector) and turns them into xpaths using [xpath-builder](https://github.com/featurist/xpath-builder)

### Install

npm install css-to-xpath

### License

BSD

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