我有一个这样的html代码:
<div class="address">
<strong>Max Mustermann </strong>
<br>Secondstreet 12
<br>1234 New York
<br>
<br>
<br>
</div>
这是我的代码:
html = html.replace("<br>", "br34k");
Document doc = Jsoup.parse(html);
Elements divs = doc.select("div.address");
StringBuilder divResult = new StringBuilder();
for (Element div : divs) {
divResult.append(div.text());
}
String result = divResult.toString();
result = completeResults.replace("br34k", System.getProperty("line.separator"));
System.out.println(result);
有了这个输出看起来像:
06-18 20:00:30.290: I/System.out(623): Cafe Palio
06-18 20:00:30.290: I/System.out(623): Marktplatz 1
06-18 20:00:30.290: I/System.out(623): 79312 Emmendingen
06-18 20:00:30.290: I/System.out(623):
06-18 20:00:30.290: I/System.out(623):
06-18 20:00:30.300: I/System.out(623): Domino Stüble
06-18 20:00:30.300: I/System.out(623): Markgrafenstr. 57
06-18 20:00:30.300: I/System.out(623): 79312 Emmendingen
06-18 20:00:30.300: I/System.out(623):
06-18 20:00:30.300: I/System.out(623):
06-18 20:00:30.300: I/System.out(623): Pizza Boxx
06-18 20:00:30.300: I/System.out(623): Am Elzdamm 66
06-18 20:00:30.300: I/System.out(623): 79312 Emmendingen
但我需要的是一个没有名称的字符串,例如:
市场广场 1 79312 埃门丁根
Markgrafenstr. 57 79312 埃门丁根
等等..