0
Я использую rometools для rss-каналов. Я пытаюсь использовать html-теги внутри cdata в разделе контента элемента RSS. Вот мой код:CDATA раздел в RSS не работает - rometools
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();
}
Проблема заключается в том, что HTML-теги внутри CDATA, которые не должны быть экранированы в настоящее время побега.
Спасибо! Можете ли вы предложить какой-либо другой инструмент для этого? –