XPath utilities extracted from Firebug.
JavaScript
Switch branches/tags
Nothing to show
Latest commit 3dab4ad Nov 1, 2012 @timoxley Merge pull request #1 from component-bot/master
add .license property
Permalink
Failed to load latest commit information.
examples
.gitignore
LICENSE
Makefile
Readme.md
component.json
index.js

Readme.md

xpath

XPath utilities extracted from Firebug.

Installation

$ component install timoxley/xpath

Example

Given this html:

<html>
<body>
  <div>
  </div>
  <div>
    <ul>
      <li></li>
      <li id="someItem"></li>
    </ul>
  </div>
</body>
</html>

Get the xpath of #someItem;

var xpath = require('xpath')
xPath.getElementTreeXPath(document.getElementById('someItem'), true) // => "/html[1]/body[1]/div[2]/ul[1]/li[2]"
// Note: boolean second parameter to `getElementTreeXPath` ensures
element indices are stored in the xpath.

API

  • getElementXPath
  • getElementTreeXPath
  • getElementCSSPath
  • cssToXPath
  • getElementsBySelector
  • getElementsByXPath
  • getRuleMatchingElements
  • getElementCSSSelector

Credit

Firebug Team