Skip to content

Instantly share code, notes, and snippets.

@santoshvijapure
Created December 27, 2021 07:31
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 santoshvijapure/5af5960028449b2b99b94cd4e268391f to your computer and use it in GitHub Desktop.
Save santoshvijapure/5af5960028449b2b99b94cd4e268391f to your computer and use it in GitHub Desktop.
get a DOM node with Xpath
function getElementByXpath(path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
// *** use ***
// getElementByXpath(XpathTargetingDOMNode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment