title: How to convert a CSS selector to XPath in Javascript?
body: <p>I'm looking for the equivalent of <code>Nokogiri::CSS.xpath_for()</code>.</p>
  
  <p>I found css2xpath however the result from Nokogiri actually works, while css2xpath returns a selector that doesn't.</p>
  
  <p>The result I'm looking for would be something like this:</p>
  
  <p><code>["//div[@id = 'my_div']//*[position() = 1 and self::table]//*[position() = 1 and self::tbody]//*[position() = 2 and self::tr]//*[position() = 1 and self::td]//*[position() = 1 and self::table]//*[position() = 1 and self::tbody]//*[position() = 2 and self::tr]//*[position() = 2 and self::td]"]</code> </p>