All Projects → featurist → css-to-xpath

featurist / css-to-xpath

Licence: BSD-2-Clause license
Convert CSS selectors to XPaths, in JavaScript

Programming Languages

PogoScript
5 projects
javascript
184084 projects - #8 most used programming language
Makefile
30231 projects

css-to-xpath

Converts CSS3 selectors to their XPath equivalents.

Build Status

Usage

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:

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 and turns them into xpaths using xpath-builder

Install

npm install css-to-xpath

License

BSD

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].