Created
June 27, 2015 16:08
-
-
Save mediavrog/f3281edae374e44aff3b to your computer and use it in GitHub Desktop.
Javascript find by XPath
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) { | |
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
} | |
console.log( getElementByXpath("//html[1]/body[1]/div[1]") ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment