Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how get Only text from Javafx2 HTMLEditor

I have a HTMLEditor and i have typed "My Simple Text".

 @FXML
 public HTMLEditor htmlEditor;

when say

htmlEditor.getHtmlText();

this return

<html><head></head><body contenteditable="true"><p style="text-align: left;"><font face="'Segoe UI'">My Simple Text</font></p></body></html>

But want text without html tag i.e.

My Simple Text

how can i do it?
like image 613
java baba Avatar asked Mar 20 '23 14:03

java baba


1 Answers

This is actually dead simple with Jsoup.

public static String html2text(String html) {
    return Jsoup.parse(html).text();
}

source : Remove HTML tags from a String

like image 173
ans1genie Avatar answered Mar 28 '23 10:03

ans1genie