Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove Html tag in android?

I am creating one sample project in android. i am using sample rss feed.

In xml description coming like this,

 <![CDATA[
    <p>15&nbsp;Mar&nbsp;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&#39;s leader and the Railway Minister, Mr.Dinesh Trivedi from the Council of Ministers.</p><br clear="all" />
    ]]>

i want to display like this,

Parliament was today disrupted over the issue of removal of Trinamool Congress&#39;s leader and the Railway Minister, Mr.Dinesh Trivedi from the Council of Ministers.

can anyone tell the idea to do this. thanks.

like image 620
Jeeva Avatar asked Mar 15 '12 13:03

Jeeva


3 Answers

do it as below:

String plain = Html.fromHtml("your_html_string").toString();
like image 131
waqaslam Avatar answered Oct 08 '22 18:10

waqaslam


       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("&nbsp;"," ");
       html = html.replaceAll("&amp;"," ");

Here is a piece of my code.

like image 30
sdfwer Avatar answered Oct 08 '22 18:10

sdfwer


This might work:

myHtmlString.replaceAll("s/<(.*?)>//g","");

Or

Html.fromHtml(htmlSrc).toString();

But there can be some bugs on the last one.

like image 43
Andreas Løve Selvik Avatar answered Oct 08 '22 19:10

Andreas Løve Selvik