如何在 Javascript 中找到第一个常见的 XPath 祖先? [英] Howto find the first common XPath ancestor in Javascript?

查看:28
本文介绍了如何在 Javascript 中找到第一个常见的 XPath 祖先?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个 XPath,例如:

<前>/html/body/div[3]/div[4]/table/tbody/tr[2]/td[4] 和/html/body/div[3]/div[4]/table/tbody/tr[2]/td[3]/a[2]

我现在如何找到第一个共同祖先?在这种情况下,它将是 /html/body/div[3]/div[4]/table/tbody/tr[2]/.

我发现了这个问题,但解决方案在ruby 并没有真正给我一个线索如何在 Javascript 中做到这一点.有谁能够帮助我?谢谢.

解决方案

这似乎是针对 JS 而不是 XSLT,尽管共同因素是元素的 XPATH.

I have two XPaths, for example:

/html/body/div[3]/div[4]/table/tbody/tr[2]/td[4] and
/html/body/div[3]/div[4]/table/tbody/tr[2]/td[3]/a[2]

How can I find the first common ancestor now? In this case it would be /html/body/div[3]/div[4]/table/tbody/tr[2]/.

I found this question but the solution is in ruby and doesn't really give me a clue how to do it in Javascript. Can anybody help me? Thank you.

解决方案

This seems to be for JS and not XSLT, although the common factor being XPATHs of the elements.

这篇关于如何在 Javascript 中找到第一个常见的 XPath 祖先?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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