gpt4 book ai didi

email - 如何在JAVA中从ckeditor生成的html中提取纯文本

转载 作者:行者123 更新时间:2023-12-04 22:21:59 24 4
gpt4 key购买 nike

我正在使用 ckeditor 来撰写电子邮件,我正在使用它生成的 html 发送 html 电子邮件广告我也需要文本版本,因此在电子邮件中同时使用 html 和纯文本版本将避免垃圾邮件。

在java中从ckeditor html代码获取文本的方法是什么?

最佳答案

这是一个非常简单的 JavaScript 调用:

CKEDITOR.instances.yourEditorInstance.getData() 

返回:
<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>

然而:
CKEDITOR.instances.yourEditorInstance.editable().getText() 

返回:
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.

关于email - 如何在JAVA中从ckeditor生成的html中提取纯文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15065132/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com