Created
November 13, 2015 19:57
-
-
Save emrahgunduz/1bc2e52ca336e397889d to your computer and use it in GitHub Desktop.
Javascript XPATH traverse for given path
This file contains 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 getElementByXpath(path) { | |
var result = document.evaluate(path, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); | |
for (var i = result.snapshotLength - 1; i >= 0; i--){ | |
console.log(result.snapshotItem(i)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment