Skip to content

Instantly share code, notes, and snippets.

@jpaugh
Created September 30, 2020 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpaugh/a07b369e41c7ba03e8a729c8cb8cc122 to your computer and use it in GitHub Desktop.
Save jpaugh/a07b369e41c7ba03e8a729c8cb8cc122 to your computer and use it in GitHub Desktop.
How to test XPath in the browser
function iterate(i) {
var result = [];
do {
var next = i.iterateNext();
result[result.length] = next;
} while (next != null)
return result;
}
iterate(document.evaluate("//a[@href and data-mediatype]", document, null, XPathResult.ANY_TYPE))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment