Skip to content
/ xpath Public
forked from timoxley/xpath

XPath utilities extracted from Firebug.

License

Notifications You must be signed in to change notification settings

yattias/xpath

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

XPath utilities extracted from Firebug.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 71.8%
  • HTML 26.2%
  • Makefile 2.0%