How to extract plain text from generated ckeditor html in JAVA

I use ckeditor to compose emails, I use the html generated by him to send html emails, I also need a text version. Therefore, the presence of both html and text version in electronic messages will avoid spam.

What is the way to get text from ckeditor html code in java.

+4
source share
1 answer

This is a pretty simple JavaScript call:

CKEDITOR.instances.yourEditorInstance.getData() 

Return:

 <h1>Apollo 11</h1> <p><b>Apollo 11</b> was the spaceflight that landed the first humans, Americans <a href="http://en.wikipedia.org/wiki/Neil_Armstrong" title="Neil Armstrong">Neil Armstrong</a> and <a href="http://en.wikipedia.org/wiki/Buzz_Aldrin" title="Buzz Aldrin">Buzz Aldrin</a>, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.</p> 

But:

 CKEDITOR.instances.yourEditorInstance.editable().getText() 

Return:

 Apollo 11 Apollo 11 was the spaceflight that landed the first humans, Americans Neil Armstrong and Buzz Aldrin, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC. 
+12
source

All Articles