Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
523 views
Welcome To Ask or Share your Answers For Others

1 Answer

you can try the following ,

Browsers can use the following to get all elements with a given tag, regardless of namespace, if the document is served as application/xhtml+xml or other XML type:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...