有人可以向我解释这段 JavaScript 代码吗?
var vTableExp = "//a[contains(@href,'newdid')]/ancestor::td/ancestor::tr/ancestor::tbody";
var vTable = dom.find(vTableExp, XPFirst);
谢谢
var vTableExp = "//a[contains(@href,'newdid')]/ancestor::td/ancestor::tr/ancestor::tbody";
var vTable = dom.find(vTableExp, XPFirst);
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个 XPATH 搜索 DOM,寻找具有后代
< 的包装
元素/code> 其
href
包含“newdid”。It is an XPATH searching against the DOM, looking for wrapping
<TBODY>
elements which have a descendant<a>
whosehref
contains "newdid".它找到第一个
tbody
,它是 aatr
元素的祖先,而tr
元素是td
元素的祖先,而td
元素是td
元素的祖先。 >a 元素,其href
包含字符串newdid
。 (IOW,假设解析的文档是 (X)HTML,请选择第一个表格的正文,该表格的单元格包含一个链接,该链接的地址包含字符串newdid
。)It finds the first
tbody
which is an ancestor of a atr
element which is an ancestor of atd
element which is an ancestor of ana
element whosehref
contains the stringnewdid
. (IOW, assuming that the parsed document is (X)HTML, select the body of the first table that has a cell containing a link whose address contains the stringnewdid
.)vTableExp
可能是一个正则表达式模式,然后正在搜索它。vTableExp
is probably a regexp pattern and then it's being searched for.