I am getting HTML text from a web service. I removed the HTML by using following code, but CSS code is still there.
Code
TextView tvNews;
tvNews.setText(Html.fromHtml(extractContent));
tvNews = (TextView) findViewById(R.id.tv_newsView);
tvNews.setText(Html.fromHtml(extractContent));
The above code removed the HTML, but CSS code is still there.
CSS Code
<style>\nbody {\n background-color: #ffffff;\n}\ntd\n{\npadding:5px;
\ncellpadding:25px;\n}\nthead th\n{\npadding:5px;\ncellpadding:25px;
\n}\n<\/style>\n<p><strong>My TEXT<\/strong> \u2013
Kindly guide me how to remove CSS code from feed and put it into textView
If you're looking for removing the html tags from html then use Jsoup( http://jsoup.org)
String textFromHtml = Jsoup.parse(MY_HTML_STRING_HERE).text();
TextView desc = (TextView) dialog.findViewById(R.id.description);
desc.setText(textFromHtml);
or for WebView
You can use this jquery method to get only text
var myContent = '<div id="test">Hello <span>world!</span></div>';
alert($(myContent).text());
That results in hello world.
http://jsfiddle.net/D2tEf/ for an example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With