How to find the first common XPath ancestor in Javascript?

I have two XPath, 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 will be /html/body/div[3]/div[4]/table/tbody/tr[2]/ .

I found this question , but the solution is in ruby ​​and actually does not let me understand how to do this in Javascript. Can anybody help me? Thanks.

+1
source share
1 answer

This is similar to JS and not XSLT, although XPATHs elements are a common factor.

-1
source

Source: https://habr.com/ru/post/1342819/


All Articles