Android 使用jsoup时如何组织提取的值?
你们如何以易于阅读的方式存储使用jsoup提取的值?因此,如果您有如下HTML代码Android 使用jsoup时如何组织提取的值?,android,json,parsing,hashmap,jsoup,Android,Json,Parsing,Hashmap,Jsoup,你们如何以易于阅读的方式存储使用jsoup提取的值?因此,如果您有如下HTML代码 <td width="200">country1 </td> <a href="http://example1.com"></a> <td width="200">country2 </td> <a href="http://example2.com"></a> <td width="200">countr
<td width="200">country1 </td>
<a href="http://example1.com"></a>
<td width="200">country2 </td>
<a href="http://example2.com"></a>
<td width="200">country3 </td>
<a href="http://example3.com"></a>
谢谢大家! 这就是你想要的吗
try {
Document doc = Jsoup.connect("http://somesite.com").get();
// Here to get the names inside tag a
Elements links = doc.select("a");
Elements linktwo = doc.select("td");
String eltwo = null;
int i = 0;
for (Element el : links) {
eltwo = linktwo.get(i).text();
//Save all the links into String Array.
array_link.add(el.text());
array_countries.add(eltwo);
i++;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
... 对象/对的列表?请告诉我更多信息或将我链接到教程。。。。有两个字段的对象?在列表视图中公开?我想大多数链接视图教程都会讨论这个问题。@DaveNewton我不确定我是否理解你的意思。当你说objects/pairs时,你指的是HashMap吗?你可以在这里看到我的答案:[LINK][1][1]:
try {
Document doc = Jsoup.connect("http://somesite.com").get();
// Here to get the names inside tag a
Elements links = doc.select("a");
Elements linktwo = doc.select("td");
String eltwo = null;
int i = 0;
for (Element el : links) {
eltwo = linktwo.get(i).text();
//Save all the links into String Array.
array_link.add(el.text());
array_countries.add(eltwo);
i++;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}