Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Convert simple xpaths to CSS selectors.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
example
.gitignore
Makefile
Readme.md
component.json
index.js

Readme.md

xpath2css

Convert simple xpath to css selector.

Installation

$ component install xpath2css

Example

  var xpath2css = require('xpath2css')
  xpath2css('//a[@id="bleh"]') // => a#bleh
  xpath2css('//ul/li') // => ul > li 
  xpath2css('//div[@class="comment"]') // => div.comment
  xpath2css('//ul/li[3]') // => ul > li:nth-of-type(3)
  xpath2css('//body//div[@data-binding="currentTime"]') // => body div[data-binding=currentTime]
  xpath2css('//div[@id="shoe"][2]/span[@class="body"]//a[contains(@class, "leather")]//img[1]') 
  // => div#shoe:nth-of-type(2) > span.body a[class*=leather] img:first-of-type

Credits

JS code adapted as a component from https://gist.github.com/3320053 Ported by Dither from cssify

Something went wrong with that request. Please try again.