Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a function that converts HTML to plaintext?

Tags:

java

html

android

Is there a "hocus-pocus" function, suitable for Android, that converts HTML to plaintext?

I am referring to a function like the clipboard conversion operation found in browsers like Internet Explorer, Firefox, etc: If you select all rendered HTML inside the browser and copy/paste it to a text editor, you will receive (most of) the text, without any HTML tags or headers.

In a similar thread, I saw a reference to html2text but it's in Python. I am looking for an Android/Java function.

Is there something like this available or must I do this myself, using Jsoup or Jtidy?

like image 631
Regex Rookie Avatar asked Mar 04 '11 15:03

Regex Rookie


1 Answers

I'd try something like:

String html = "<b>hola</b>";
String plain = Html.fromHtml(html).toString();
like image 52
Cristian Avatar answered Sep 19 '22 18:09

Cristian