A pegjs grammar to convert css selectors to their respective xpath selector. Try it online http://pegjs.majda.cz/online.