看看ROME对rss和atom的操作

// SyndFeed feed = SyndImpl.newSyndFeed("aaa", host, "bbb", FeedType.RSS_200);
SyndFeed feed  =   new  com.sun.syndication.feed.synd.SyndFeedImpl();
feed.setFeedType(
" rss_2.0 " );
feed.setTitle(
" title " );
feed.setLink(
" link " );
feed.setDescription(
" description " );
//  建立一个 rss 2.0的feed

List list 
=   new  LinkedList();
SyndEntry entry 
=   new  SyndEntryImpl();  //  feed其中的一个 entry, 即其中一篇文章
SyndContent description  =   new  SyndContentImpl();  //  文章的描述

entry.setTitle(
" ROME v1.0 " );  //  设置文章标题
entry.setLink( " http://wiki.java.net/bin/view/Javawsxml/Rome01 " );
entry.setPublishedDate(
new  Date());
description.setType(
" text/plain " );
description.setValue(
" Initial release of ROME " );
entry.setDescription(description);

list.add(entry);
feed.setEntries(list); 
//  设置feed的文章列表,

response.setContentType(
" text/xml " );
// FeedUtil.outPutFeed(feed, out);  //  向客户端输出xml
new  SyndFeedOutput().output(feed, out);

 

其中FeedType为以下同种中的一种
public static final String RSS_090 = "rss_0.9";
public static final String RSS_092 = "rss_0.92";
public static final String RSS_093 = "rss_0.93";
public static final String RSS_094 = "rss_0.94";
public static final String RSS_091_Netscape = "rss_0.91";
public static final String RSS_091_Userland = "rss_0.91";
public static final String RSS_100 = "rss_1.0";
public static final String RSS_200 = "rss_2.0";
public static final String ATOM_030 = "atom_0.3";
public static final String ATOM_100 = "atom_1.0";


用ROME ,就可以很简单的生成rss, atom或者将rss转化成atom, 等操作..
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值