css-to-xpath
Advanced tools
Comparing version
(function() { | ||
var self = this; | ||
var parser, xpathBuilder, Expression, parse; | ||
var parser, xpathBuilder, Expression, parse, convertToXpath; | ||
parser = require("bo-selector").parser; | ||
@@ -14,3 +14,7 @@ xpathBuilder = require("xpath-builder").dsl(); | ||
}; | ||
exports.parse = parse; | ||
convertToXpath = function(selector) { | ||
return parse(selector).toXPath(); | ||
}; | ||
convertToXpath.parse = parse; | ||
module.exports = convertToXpath; | ||
}).call(this); |
{ | ||
"name": "css-to-xpath", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Converts CSS selectors to xpaths", | ||
@@ -34,3 +34,3 @@ "main": "js/css_to_xpath.js", | ||
"name": "Josh Chisholm", | ||
"email": "joshchisholm@gmail.com", | ||
"email": "josh@featurist.co.uk", | ||
"url": "http://featurist.co.uk/" | ||
@@ -37,0 +37,0 @@ }, |
# css-to-xpath | ||
Converts CSS3 selectors to their XPath equivalents | ||
Converts [CSS3 selectors](http://www.w3.org/TR/css3-selectors/#selectors) to their XPath equivalents. | ||
[](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 ')])] | ||
``` | ||
### 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 |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
28791
3.22%278
1.46%29
222.22%