Created
March 17, 2017 18:10
-
-
Save lovasoa/bb72af1f0fdd0294b9e8262100e96ff5 to your computer and use it in GitHub Desktop.
Simple xpath function for querying the DOM. Takes a string and returns an array of dom nodes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function xpath(query) { | |
var arr = []; | |
var results = document.evaluate(query, document, null, XPathResult.ANY_TYPE, null ); | |
while(r = results.iterateNext()) arr.push(r); | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment