Skip to content

And condition does not work if arguments are reversed. #46

Description

@smatei

Hi,

I have found that the xpath

//div[@data-hveid and @class='g']

does not work, returns 0 elements

but the xpath

//div[@class='g' and @data-hveid]

does work, returning 1 element. The code example is below (jsoup 1.11.3, xsoup 0.3.1).

`

	String html = "<!DOCTYPE html>" +
		"<html>" +
		"  <head>" +
		"    <title>test</title>" +
		"  </head>" +
		"  <body>" +
		"  <div class=\"g\" data-hveid=\"CAYQAA\">" +
		"  </div>" +
		"  </body>" +
		"</html>";
	Document document = Jsoup.parse(html);

	// does not work
	String xpath = "//div[@data-hveid and @class='g']";

	// does work
	//String xpath = "//div[@class='g' and @data-hveid]";

	XElements elements = Xsoup.compile(xpath).evaluate(document);
	System.out.println(elements.getElements().size());

	for (Element element : elements.getElements())
	{
	  System.out.println(element.toString());
	}

`

I think it should work both ways.

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