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

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

Open
smatei opened this issue Jun 26, 2019 · 0 comments
Open

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

smatei opened this issue Jun 26, 2019 · 0 comments

Comments

@smatei
Copy link

smatei commented Jun 26, 2019

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.

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

1 participant