Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.

JavaScript
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

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.
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900