How to access an HTML element using XPath in IE8?

Am I stuck as a problem accessing an HTML element in IE using XPath in Javascript? I have already tried using the selectNodes () method, but only for XML, this is not work for XPath HTML element.

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

But it does not return any item. Can anyone suggest me how to access an HTML element in IE XPath using Javascript? Any suggestion is appreciated.

-Thanks in advance.

+3
source share
3 answers

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

http://sourceforge.net/projects/html-xpath/

It also allows you to combine APIs between IE and other browsers.

+2
source

,

, , , application/xhtml + xml XML :

    var titles = document.getElementsByTagNameNS("*","input[@name='action']");  
+2

Try Wicked Good XPath: https://code.google.com/p/wicked-good-xpath/

This is the smallest and fastest JavaScript version of the XPath library and is supported by Google.

+1
source

All Articles