XPath utilities extracted from Firebug.
$ component install timoxley/xpath
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.
- getElementXPath
- getElementTreeXPath
- getElementCSSPath
- cssToXPath
- getElementsBySelector
- getElementsByXPath
- getRuleMatchingElements
- getElementCSSSelector