You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's assume we have same elements div1, div2, div3 with a similar inner tag structure.
If I have element div2 and try element.selectXpath(path), I have the result from div1. Similar with the element div3. If I have the element div3 and call element.selectXpath(path) I have the result from div1.
By the way element.select(selector) works just as expected, div1 selects only inside div1 scope, div1 inside div1 scope, etc.
Rather than a picture and a narrative, your report would be a lot better with a simple repeatable test case showing what you're trying to do, what you're getting, and what you want instead. You haven't mentioned what XPath query you are using so I can't evaluate your issue.
However - by referencing the //body test case, my guess is that you are using absolute queries? The element.selectXpath() method uses the given element as the context, but the entire DOM is still available. If you provide a relative query, it will be relative to the context element, and if you provide an absolute query, it will be absolute to the entire DOM. Hence, the test case.
jhy
added
not-a-bug
This issue is not a bug; it is working as per spec
and removed
needs-more-info
More information is needed from the reporter to progress the issue
labels
Feb 18, 2023
Example:
Let's assume we have same elements
div1
,div2
,div3
with a similar inner tag structure.If I have element
div2
and tryelement.selectXpath(path)
, I have the result fromdiv1
. Similar with the elementdiv3
. If I have the elementdiv3
and callelement.selectXpath(path)
I have the result fromdiv1
.By the way
element.select(selector)
works just as expected,div1
selects only insidediv1
scope,div1
insidediv1
scope, etc.Seems like this is an issue:
Inside mentioned test case.
https://github.com/jhy/jsoup/blame/be24647192f7870da500fb83650bacafed81151f/src/test/java/org/jsoup/select/XpathTest.java#L38
assertEquals(1, div.selectXpath("//body").size()); // the whole document is visible on the div context
Originally posted by @zaurkadiev in #1856 (comment)
The text was updated successfully, but these errors were encountered: