Created
May 7, 2022 09:02
-
-
Save moskalukigor/fe4b990158d9c33f116c222c21fe1731 to your computer and use it in GitHub Desktop.
Javascript search 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