intacto27
intacto27

Reputation: 9

Get all tr on page by class

I need to get all tables with some class, and get all id of rows with some class in this tables. My code is next:

HtmlPage page = webClient.getPage("http://www.somesite.com");
HtmlTable table = div.querySelector(".table-classname");
for (HtmlTableRow row : table.getRows())
{
String id = row.getAttribute("id");
System.out.println(id);
}

But it works only for first table on the page. How can i do this with all tables on the page?

Upvotes: 0

Views: 210

Answers (1)

maszter
maszter

Reputation: 3720

You should probably use querySelectorAll instead of querySelector and iterate through the list of returned elements

Upvotes: 1

Related Questions