Created
September 30, 2013 09:39
-
-
Save m1el/6761486 to your computer and use it in GitHub Desktop.
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 $x(xpath, root) { | |
root = root ? root : document; | |
try { | |
var nodes = document.evaluate(xpath, root, null, 7, null); | |
} catch(e) { | |
return []; | |
} | |
var result = []; | |
for(var i = 0; i < nodes.snapshotLength; i++) { | |
result[i] = nodes.snapshotItem(i); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment