Skip to content

Instantly share code, notes, and snippets.

@mediavrog
Created June 27, 2015 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mediavrog/f3281edae374e44aff3b to your computer and use it in GitHub Desktop.
Save mediavrog/f3281edae374e44aff3b to your computer and use it in GitHub Desktop.
Javascript find by XPath
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