Skip to content

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

Description

@smatei

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions