我正在尝试从以下网址获取标记中的文本:http://www.mcpss.com/?PN='News2'&SubP='DNewsStory'&gn=&NewsID=47318&ShowNav=&StoryGroup=Current
<td class="header">
OPEN HOUSE SCHEDULED AT CLARK-SHAW
</td>
<p><span style="font-size: 12pt;">January 16, 2013 - Due to the relocation of Murphy High School to the Clark-Shaw campus and the necessary construction that is still ongoing, Clark-Shaw school did not participate in the magnet school “See and Sign” January 11 and 12<sup>th</sup>. We would like to resume giving school tours and meeting interested parents. Therefore, we are planning an “Open House” on Friday, January 25 from 9:00 a.m.- 12:00 p.m. to coincide with our school’s Science Fair Open House that is scheduled for that day.</span></p>
<p><span style="font-size: 12pt;"> </span></p>
<p><span style="font-size: 12pt;">Please share this information with your friends and neighbors. Magnet School applications are available now online.</span></p>
<p> </p>我想在android应用程序中表示文本,如下所示:
*计划在CLARK-SHAW举行的开放日
2013年1月16日-由于墨菲高中搬迁到克拉克-肖校区,必要的建设仍在进行中,克拉克-肖学校没有参加磁铁学校的“见并签署”1月11日和12日。我们希望恢复提供学校参观和会见感兴趣的家长。因此,我们计划在1月25日(星期五)上午9:00 -下午12:00举行“开放参观”。恰逢我校定于当天举行的科学博览会开放日。
请与您的朋友和邻居分享此信息。磁石学校申请现已在线提供。*
我怎样才能在android中获得它。
发布于 2013-01-22 13:32:41
使用jsoup http://jsoup.org/,您可以获得以下内容
下载jsoup.jar文件,然后将其添加到您的libs文件夹中,然后转到安卓依赖项,右键单击>> build path >> configure build path >> add JARS>> libs >>,然后选择您下载的jsoup.jar文件
try {
String website="http://www.mcpss.com/?PN='News2'&SubP='DNewsStory'&gn=&NewsID=47318&ShowNav=&StoryGroup=Current";
Document doc = Jsoup.connect(website).get();
Elements el=doc.getElementsByClass("header");
String text=el.text();
} catch (Exception e) {
Log.wtf("name of activity","error message to show in log", e);
}发布于 2013-01-22 14:05:01
由于这是一个超文本标记语言文档,请尝试对TextView使用Html.fromHtml(字符串),或者尝试使用webview取决于标签。
对于TextView,您可以像这样使用
TextView txt=new TextView(getApplicationContext());
String str="<td class=\"header\">"+
"OPEN HOUSE SCHEDULED AT CLARK-SHAW"+
"</td>"+
"<p><span style=\"font-size: 12pt;\">January 16, 2013 - Due to the relocation of Murphy High School to the Clark-Shaw campus and the necessary construction that is still ongoing, Clark-Shaw school did not participate in the magnet school “See and Sign” January 11 and 12<sup>th</sup>. We would like to resume giving school tours and meeting interested parents. Therefore, we are planning an “Open House” on Friday, January 25 from 9:00 a.m.- 12:00 p.m. to coincide with our school’s Science Fair Open House that is scheduled for that day.</span></p>"+
"<p><span style=\"font-size: 12pt;\"> </span></p>"+
"<p><span style=\"font-size: 12pt;\">Please share this information with your friends and neighbors. Magnet School applications are available now online.</span></p>"+
"<p> </p>";
txt.setText(Html.fromHtml(str));对于WebView,尝试使用webview.loadData();
https://stackoverflow.com/questions/14451986
复制相似问题