I\'m new to DOM querying and I\'m wondering if it is possible to query DOM elements directly by Xpath in a similar way to the below-mentioned code?
document.
The equivalent statement using only XPath would be
xPathResult = document.evaluate('//*[@id="searchInput"]', document); if(xPathResult){ element = xPathResult.iterateNext(); }
Have a look at the Intro to XPath in the browser on MDN for some more examples and usages.