Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get element by xpath in javascript

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]") );
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #element #xpath #javascript
ADD COMMENT
Topic
Name
2+9 =