目前,这是我从Yahoo!获得的RSS新闻提要。
<item>
<title>
Cheapest Stocks in Egypt Post Best Rally in Year on Army Control
</title>
<link>http://us.rd.yahoo.com/finance/external/bloomberg/rss/SIG=13gf1d488/*http://www.bloomberg.com/news/2013-10-01/cheapest-stocks-in-egypt-post-best-rally-in-year-on-army-control.html?cmpid=yhoo
</link>
<description>
[at Bloomberg] - Egyptian stocks posted their best quarter in a year as increased political stability combined with the world’s cheapest equities lured investors.
</description>
<guid isPermaLink="false">yahoo_finance/1833836173</guid>
<pubDate>Tue, 01 Oct 2013 22:00:00 GMT</pubDate>
</item>
在我的UI控件中显示
description
的内容对我来说非常简单。我可以自己决定UI外观(字体大小,字体颜色)。但是,如果我要从Google检索内容,事情会变得更加困难!
这是一个例子
<item>
<title>Genting, UMW weigh on KLCI - The Star Online</title>
<link>http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNE006d3wlqjgGfQAqGV8S4VFtQY3g&url=http://www.thestar.com.my/Business/Business-News/2013/09/25/Genting-UMW-weigh-on-KLCI.aspx
</link>
<guid isPermaLink="false">tag:news.google.com,2005:cluster=http://www.thestar.com.my/Business/Business-News/2013/09/25/Genting-UMW-weigh-on-KLCI.aspx</guid>
<pubDate>Wed, 25 Sep 2013 01:21:04 GMT</pubDate>
<description>
<table border="0" cellpadding="2" cellspacing="7" style="vertical-align:top;"><tr><td width="80" align="center" valign="top"><font style="font-size:85%;font-family:arial,sans-serif"></font></td><td valign="top" class="j"><font style="font-size:85%;font-family:arial,sans-serif"><br /><div style="padding-top:0.8em;"><img alt="" height="1" width="1" /></div><div class="lh"><a href="http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNE006d3wlqjgGfQAqGV8S4VFtQY3g&url=http://www.thestar.com.my/Business/Business-News/2013/09/25/Genting-UMW-weigh-on-KLCI.aspx"><b>Genting, UMW weigh on KLCI</b></a><br /><font size="-1"><b><font color="#6f6f6f">The Star Online</font></b></font><br /><font size="-1">KUALA LUMPUR: <b>Malaysia's</b> blue chips extended their losses for third day on Wednesday, with the FBM KLCI opened down nearly five points on mild selling of Genting <b>Bhd</b>, UMW and BAT, in line with the subdued Asian bourses. At 9am, the KLCI was down 4.42 <b>...</b></font><br /><font size="-1" class="p"></font><br /><font class="p" size="-1"><a class="p" href="http://news.google.com/news/more?ncl=dQyXEqkX7SN2KKM&ned=us"><nobr><b>and more »</b></nobr></a></font></div></font></td></tr></table>
</description>
</item>
如您所见,
description
带有各种HTML标记,这是我不感兴趣的。我只对纯内容感兴趣,而不对格式信息感兴趣。有什么简单的方法可以实现我的目标?
最佳答案
Html
类具有fromHtml()
方法,可从字符串中删除所有标签:
String noHtml = Html.fromHtml(HTML_STRING).toString();
看到这里:http://developer.android.com/reference/android/text/Html.html#fromHtml(java.lang.String)