我在android中创建了一个示例项目。我正在使用示例rss feed。
在这样的xml描述中,
<![CDATA[
<p>15 Mar 2012</p>
<a href="http://newsonair.nic.in/full_news.asp?TOP2">
<p style='FONT-SIZE: 12px; LINE-HEIGHT: 150%' align='justify'>
<img style='FLOAT: left; MARGIN-RIGHT: 5px' height='100' width='100' src=http://www.newsonair.nic.in/writereaddata/news_pictures/PICNEWS1.jpg?
0.7055475></a><br/>
Parliament was today disrupted over the issue of removal of Trinamool Congress's leader and the Railway Minister, Mr.Dinesh Trivedi from the Council of Ministers.</p><br clear="all" />
]]>
我想这样显示,
Parliament was today disrupted over the issue of removal of Trinamool Congress's leader and the Railway Minister, Mr.Dinesh Trivedi from the Council of Ministers.
任何人都可以说出这个想法。 感谢。
答案 0 :(得分:34)
按以下方式执行:
String plain = Html.fromHtml("your_html_string").toString();
答案 1 :(得分:28)
html = html.replaceAll("<(.*?)\\>"," ");//Removes all items in brackets
html = html.replaceAll("<(.*?)\\\n"," ");//Must be undeneath
html = html.replaceFirst("(.*?)\\>", " ");//Removes any connected item to the last bracket
html = html.replaceAll(" "," ");
html = html.replaceAll("&"," ");
这是我的一段代码。
答案 2 :(得分:2)
这可能有效:
myHtmlString.replaceAll("s/<(.*?)>//g","");
或者
Html.fromHtml(htmlSrc).toString();
但是最后一个可能会有一些错误。