Click here to Skip to main content
14,454,243 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi Everyone,

I want get html element using XPath. I can able get html element using XPath with below code in Chrome and FireFox but not in IE.

return document.evaluate(\"//input\", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue


How can I get html element using Xpath in Javascript.

Regards,
Rajendar.
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

document.evaluate is not supported in IE (up to IE 10, not sure about 11). Use jQuery, Sizzle or some other library.

there is this[^] for IE only if you're willing to torture your self :)


If this helps please take time to accept the solution. Thank you.
   
Comments
Member 11085647 16-Dec-14 3:02am
   
I am using ExecuteScript method in VS cuit to execute Javascript code. It is working fine in chrome and Firefox but not in IE. Can you help me to get element by XPath in IE11?
Sinisa Hajnal 16-Dec-14 4:33am
   
It is still javascript. Read my solution, either use one of the libraries or set the code so it detects which browser is calling and go to working code (I provided you with the link)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100