如何在IE8中使用XPath访问HTML元素? [英] How to access HTML element using XPath in IE8?

查看:914
本文介绍了如何在IE8中使用XPath访问HTML元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用JavaScript中的XPath访问HTML元素时遇到了问题?
我已经尝试过使用selectNodes()方法,但是它仅适用于XML,它不适用于HTML元素的XPath。

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

但它没有返回任何元素。
任何人都可以建议我如何通过使用Javascript的XPath访问IE中的HTML元素?
任何建议表示赞赏。



- 预先感谢。

解决方案

您可能也会喜欢这个解决方案,以在IE中为HTML添加xpath支持:
$ b http://sourceforge.net/projects/html-xpath/

这有利于统一IE与其他浏览器之间的API也是如此。

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:

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

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

这篇关于如何在IE8中使用XPath访问HTML元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆