Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xpath @class= does not work as in chrome. #47

Open
smatei opened this issue Jun 26, 2019 · 1 comment
Open

Xpath @class= does not work as in chrome. #47

smatei opened this issue Jun 26, 2019 · 1 comment

Comments

@smatei
Copy link

smatei commented Jun 26, 2019

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?

@diantongren
Copy link

I try with another xpath framework(JsoupXpath) and I get only one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants