Alex Ironz
Alex Ironz

Reputation: 13

Jsoup HTML Parsing with specific tags

I have HTML page with code

<td class="c" nowrap>993</td>

i need to parse this and to get 993

I try this code

doc.select("td.c.nowrap").text()

but it is doesnt work. Please, type me correct variant

Upvotes: 0

Views: 294

Answers (1)

ashatte
ashatte

Reputation: 5538

nowrap is an attribute so it should be enclosed in square brackets (as per the documentation):

Element e = doc.select("td.c[nowrap]").first();
String number = e.text(); // will be 993

That will select the first instance of a <td> tag that has class="c" and the nowrap attribute.

Upvotes: 1

Related Questions