Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OR operator for JSOUP select() method

Tags:

jsoup

I am trying to find all <div class="name1"> or <div class="name2"> tags in one page/document.

How can I use OR operator in doc.select("div.name1 OR div.name2")?

like image 580
User1234 Avatar asked Jun 30 '14 07:06

User1234


1 Answers

The select method of JSoup implements more or less the CSS selector syntax. So you can very simply use the CSS way of specifying alternatives, i.e. using ,. This should work:

doc.select("div.name1,div.name2");
like image 69
luksch Avatar answered Sep 27 '22 21:09

luksch