xpath.js 366 B

12345678910111213141516
  1. exports = function(xpath) {
  2. var ret = [];
  3. var nodesSnapshot = document.evaluate(
  4. xpath,
  5. document,
  6. null,
  7. XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
  8. null
  9. );
  10. for (var i = 0; i < nodesSnapshot.snapshotLength; i++) {
  11. ret.push(nodesSnapshot.snapshotItem(i));
  12. }
  13. return ret;
  14. };
  15. module.exports = exports;