How to access the HTML element using XPath in IE8?


I am stuck with as issue of accessing HTML element in IE using XPath in Javascript? I already tried with selectNodes() method but its for XML only, it does not work for XPath of HTML element.

document.setProperty("SelectionLanguage", "XPath");
var mydoc=document.loadXML(document);
var nodes=mydoc.selectNodes("//input[@name='action']");

But its not returning any element. Can anyone suggest me how to access HTML element in IE by XPath using Javascript? Any suggestion is appreciated.

-Thanks in advance.

You might also like this solution to add xpath support for HTML in IE:

This has the benefit of unifying the API between IE and other browsers, as well.