Xpath @class= does not work as in chrome.
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 474
- Forks
- 148
- PR merge metrics
- No merged PRs in 30d
Description
If I run the following code:
`
String html = "<!DOCTYPE html>" +
"<html>" +
" <head>" +
" <title>test</title>" +
" </head>" +
" <body>" +
" <div class=\"g\">" +
" </div>" +
" <div class=\"g x y t\">" +
" </div>" +
" </body>" +
"</html>";
Document document = Jsoup.parse(html);
String xpath = "//div[@class='g']";
XElements elements = Xsoup.compile(xpath).evaluate(document);
System.out.println(elements.getElements().size());
for (Element element : elements.getElements())
{
System.out.println(element.toString());
}
`
I get two elements as out put:
<div class="g">
and
<div class="g x y t">
In Chrome, I get only one, the one with the exact match. Who is wrong, xsoup or Chrome?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Xsoup.compile(xpath).evaluate(document) entry point shown in the report and compare how the @class predicate is interpreted against the supplied HTML. No source file or test is named; done means determining the intended XPath behavior and adding or updating coverage so the reported class-matching result is consistent with that behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100