首页 \ 问答 \ RSS中的CDATA部分无法正常工作 - rometools(CDATA section in RSS not working - rometools)

RSS中的CDATA部分无法正常工作 - rometools(CDATA section in RSS not working - rometools)

我正在使用rometools作为rss feed。 我试图在RSS项目的内容部分中使用cdata内的html标签。 这是我的代码:

public class RssView extends AbstractRssFeedView {
@Override
 protected List<com.rometools.rome.feed.rss.Item> buildFeedItems(Map<String, Object> map,
                                                                HttpServletRequest httpServletRequest,
                                                                HttpServletResponse httpServletResponse) throws Exception {
    List<Item> items = new ArrayList<>();
    Object ob = map.get("feeds");
    if (ob instanceof List){
        for(int i = 0; i < ((List<?>)ob).size(); i++){
            Object articleObj = ((List<?>) ob).get(i);

            Article article = (Article)articleObj;
            Item item = new Item();
            item.setTitle(article.getTitle());

            Guid guid = new Guid();
            guid.setValue(item.getLink());
            item.setGuid(guid);

            item.setPubDate(article.getCreatedTime());

            Description description = new Description();
            description.setValue(article.getDescrition());
            item.setDescription(description);

            Content content = new Content();
            content.setValue(buildContent(article));
            item.setContent(content);
            items.add(item);
        }
    }
    return items;
}
@Override
protected void buildFeedMetadata(Map<String, Object> model, Channel channel,
                                 HttpServletRequest request) {
    channel.setTitle("Article");
    channel.setLink("http://www.");
    channel.setDescription("desciprtion");
    channel.setLanguage("en-us");
}

private String buildContent(Article article) {
    StringBuilder sb = new StringBuilder();

    sb.append("<![CDATA[" +
            "<!doctype html>\n]]>");

    return sb.toString();
}

问题是cdata中不应该被转义的html标签正在被转义。


I am using rometools for rss feeds. I am trying to use html tags inside cdata in content section of the RSS item. Here is my code:

public class RssView extends AbstractRssFeedView {
@Override
 protected List<com.rometools.rome.feed.rss.Item> buildFeedItems(Map<String, Object> map,
                                                                HttpServletRequest httpServletRequest,
                                                                HttpServletResponse httpServletResponse) throws Exception {
    List<Item> items = new ArrayList<>();
    Object ob = map.get("feeds");
    if (ob instanceof List){
        for(int i = 0; i < ((List<?>)ob).size(); i++){
            Object articleObj = ((List<?>) ob).get(i);

            Article article = (Article)articleObj;
            Item item = new Item();
            item.setTitle(article.getTitle());

            Guid guid = new Guid();
            guid.setValue(item.getLink());
            item.setGuid(guid);

            item.setPubDate(article.getCreatedTime());

            Description description = new Description();
            description.setValue(article.getDescrition());
            item.setDescription(description);

            Content content = new Content();
            content.setValue(buildContent(article));
            item.setContent(content);
            items.add(item);
        }
    }
    return items;
}
@Override
protected void buildFeedMetadata(Map<String, Object> model, Channel channel,
                                 HttpServletRequest request) {
    channel.setTitle("Article");
    channel.setLink("http://www.");
    channel.setDescription("desciprtion");
    channel.setLanguage("en-us");
}

private String buildContent(Article article) {
    StringBuilder sb = new StringBuilder();

    sb.append("<![CDATA[" +
            "<!doctype html>\n]]>");

    return sb.toString();
}

The problem is that html tags inside cdata that aren't supposed to be escaped are being escape.


原文:https://stackoverflow.com/questions/36005095
更新时间:2019-12-03 08:12

最满意答案

你想要做什么,罗马不可能做到这一点。 请参阅此问题: https//github.com/rometools/rome/issues/280


What you are trying to do, is not possible with Rome a the moment. See this issue: https://github.com/rometools/rome/issues/280

2016-03-18

相关问答

更多

使用C#显示销售管道漏斗图窗口8应用程序(Display Sales Pipe funnel chart windows 8 app using C#)

您无法使用CRM SDK在其他应用程序中显示漏斗图。 为此,您必须使用另一个图表API,并使用CRM SDK从CRM获取数据。 看看这张图表api。 You can't use CRM SDK to show the funnel chart in another application. For that you have to use another chart API, and get the data from CRM, with CRM SDK. Take a look in this

谷歌云翻译和Java的编码错误(Wrong encoding of google cloud translate and Java)

这不是UTF8 / UTF16的问题。 谷歌的答案是HTML编码。 https://en.wikipedia.org/wiki/Unicode_and_HTML 如果要在xml / html上下文中仅使用ASCII传输unicode字符,这很常见。 It's not a problem of UTF8 / UTF16. The answer of google is html encoded. https://en.wikipedia.org/wiki/Unicode_and_HTML This

在MS SQL中查找序列中缺少的数字(Find missing numbers in a sequence in MS SQL)

尝试这个: 如果您需要获得更多数字,只需增加WHERE Number<=100 。 DECLARE @Tab1 TABLE (ID INT) INSERT INTO @Tab1 VALUES(1) INSERT INTO @Tab1 VALUES(3) INSERT INTO @Tab1 VALUES(5) INSERT INTO @Tab1 VALUES(7) INSERT INTO @Tab1 VALUES(9) ;WITH CTE AS ( SELECT 1 AS Number

原始#primSocketSendDone:在Socket中失败(primitive #primSocketSendDone: in Socket failed)

某处曾经有过1024个套接字限制。 vm列表可能是最好的问题 Solved it by modifying my client code to store more data less frequently (i.e. cache more in memory) and the problem went away, now i can even run 16 Pharo instances in parallel.

我添加后左侧边栏没有显示(Left sidebar not showing after I add it)

您的问题如下: 您正在registering侧边栏,这使其可在小部件区域中使用。 您正在sidebar-left.php文件中定义补充工具栏布局 但你实际上并没有告诉你的主题在任何地方拉边栏。 简要地看一下主题,他们在一些主题文件中使用get_sidebar()调用侧边栏。 所以你有两个主要选择。 一:将这些文件复制到您的子主题并添加get_sidebar('sidebar-left'); 在相同的文件中,位置可能会有所不同,但这些是以这种方式调用侧边栏的文件: 使用此方法,您还可以创建一个新的

如何在css中为模态弹出创建多个按钮(how to create multiple button for modal popup in css)

您只需要为这三个按钮添加事件侦听器。 所以,你只需要专注于这些部分: var btn = document.getElementById("myBtn"); btn.onclick = function() { modal.style.display = "block"; } 您不能拥有具有相同ID的多个元素。 这是一种犯罪。 由于多人不能持有单一护照。 所以,将它们转换为类: <button class="myBtn">butoon 1</button> <button class="

将重置按钮拖放到原始位置(Drag and drop reset button to original position)

你需要使用detach 。 当您单击reset按钮时,它会删除briefcase-droppable中的图像dragIcons加到dragIcons 。 $('#reset').click(function(e) { e.preventDefault(); var dropped_icon = $('#briefcase-droppable') .children() .detach() .removeClass('dropped

PAA是否适合在门户网站中自动执行wcm库部署和设置?(Is PAA a good candidate for automating wcm library deployment and setup in portal?)

我一直在密切关注PAA文件,我必须说这是一种非常稳定的部署应用程序的方法,需要多个depl步骤和组件。 它确实需要一个启动过程,但在多服务器环境中非常值得。 您可以执行在Ant文件中执行的所有任务以及使用wsadmin脚本界面。 因为所有设置都存储在WAS中,我只更新res env设置和WAS中的设置,并且不会因为这个原因而触摸任何道具文件。 I have been working intensively with PAA files and I must say that it is a ve

相关文章

更多

最新问答

更多
  • 读取UITextfields的值时出错(Error in reading values of UITextfields)
  • 将javascript变量分配给java变量(Assigning javascript variable to java variable)
  • ActiveRecord_Associations_CollectionProxy的未定义方法(Undefined method for ActiveRecord_Associations_CollectionProxy)
  • 返回两个字符串作为方法签名(Return two strings as method signature)
  • 在弹簧启动应用程序中自动连接对象(Auto wiring an object in spring boot application)
  • Log4j2 - 当前日期文件追加不起作用(Log4j2 - current date file append not working)
  • 如果已经使用计时器运行,如何解决不受欢迎的webrequest调用?(How to solve undesirable webrequest call if it is already running with timer?)
  • 释放全局变量(Freeing global variable)
  • 如何在标头中添加单独的列以便在jqgrid中进行垂直滚动(How to add separate column in header for vertical scrolling in jqgrid)
  • Javascript / jQuery切换边栏[关闭](Javascript/jQuery Toggling Sidebar [closed])
  • 套接字客户端:没有得到DataInputStream.readUTF()的完整响应(Socket client: don't get the full response with DataInputStream.readUTF())
  • 一个月的数字表示,带或不带前导零(Numeric representation of a month, with or without leading zeros)
  • SAS proc freq用于变量的不同值(SAS proc freq for distinct value of a variable)
  • 将pkg.sub导入为other.sub(importing pkg.sub as other.sub)
  • PaperJs错误并不明显(PaperJs errors are not understable)
  • 访问正文中脚本之外的javascript var(accessing a javascript var outside of script in the body)
  • 使用PowerShell查询单个注册表子项?(Query a single registry subkey using PowerShell?)
  • 可以省去do-while循环中的“do”吗?(Can leaving out the “do” in a do-while loop still work?)
  • Firestore规则:数据为数字时条件检查失败(Firestore rules: condition check fails when data is number)
  • Python:为什么在迭代时会忽略序列的__len __()?(Python: Why is the __len__() of a sequence ignored when iterating?)
  • PlayN中没有发现OpenGL上下文错误(No OpenGL context found error in PlayN)
  • 如何在AWS CodeCommit存储库中创建文件夹?(How to create folder in AWS CodeCommit repository?)
  • awk:将结果发送到使用bash变量命名的文件(awk: send results to file named using bash variable)
  • 卸载视图时防止丢失状态(Prevent loss of state when unmounting view)
  • Android EditText字段在模拟器上运行正常,但不适用于设备(Android EditText field works fine on emulator, but not device)
  • AngularJS在条件有效的ng-repeat中禁用未选中的复选框(AngularJS Disable unchecked checkbox in ng-repeat with condition)
  • codeigniter加载一个没有任何html标题的视图进行打印(codeigniter load a view without any html header for printing)
  • Liferay porlet的动作网址中的例外情况(Exception in the action url of liferay porlet)
  • 条目(XAML表单)对象引用仅与UWP App一起使用(Entry (XAML Form) object reference null only with UWP App)
  • Spring项目中的额外Gradle任务(Extra Gradle tasks in Spring project)