Reputation: 89
I am new to android and Jsoup scene and have a small problem converting a table. using for example this link http://mywheels.ie/car-history-check/free-car-check-results/?VRN=00C31865 how can I parse the table and display the elements from the right hand side FIAT,RED,PETROL in the Log ? Thank you in advance
Upvotes: 1
Views: 1580
Reputation: 4187
import java.util.Iterator;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class JsoupTest1 {
public static void main(String[] args) {
Document doc = Jsoup.parse("<table><tr class='eventTableRow'><td id='1' class='class1'>value1</td><td id='2' class='class2'>value2</td><td id='3' class='class3'>value3</td></tr></table>");
Elements row = doc.select(".eventTableRow td");
Iterator<Element> iterator = row.listIterator();
while(iterator.hasNext())
{
Element element = iterator.next();
String id = element.attr("id");
String classes = element.attr("class");
String value = element.text();
System.out.println("Id : " + id + ", classes : " + classes+ ", value : " + value);
}
}
}
Via https://stackoverflow.com/users/159793/newbie
Upvotes: 1