Javascript得到一个节点的XPath [英] Javascript get XPath of a node

查看:89
本文介绍了Javascript得到一个节点的XPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

有没有一个独特的XPath到一个节点,所以你必须决定构建路径最合适的方法。使用可用的ID?文件中的数字位置?相对于其他元素的位置?



请参阅 getPathTo() com / questions / 2631820 / im-storage-click-coordinates-in-my-db-and-then-reloading-them-later-and-shows / 2631931#2631931>这个答案为一种可能的方法。


Is there anyway to return an XPath string of a DOM element in Javascript?

解决方案

There's not a unique XPath to a node, so you'll have to decide what's the most appropriate way of constructing a path. Use IDs where available? Numeral position in the document? Position relative to other elements?

See getPathTo() in this answer for one possible approach.

这篇关于Javascript得到一个节点的XPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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