Skip to content

Instantly share code, notes, and snippets.

@matteodelabre
Created January 13, 2023 04:26
Show Gist options
  • Save matteodelabre/1543e6095eec47acb95d78da213e6cb2 to your computer and use it in GitHub Desktop.
Save matteodelabre/1543e6095eec47acb95d78da213e6cb2 to your computer and use it in GitHub Desktop.
XPath select
const xpathSelect = (expr) => {
const iterator = document.evaluate(expr, document);
const result = [];
let current = iterator.iterateNext();
while (current) {
result.push(current);
current = iterator.iterateNext();
}
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment