写自己的rss

王朝java/jsp·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

今天看到csdn系统发来的短消息,采用RSS订阅每个类别最新文档。我查了下资料,发现有个rsslibj的开源工具可以帮助我们写自己的rss文档。当然,我这里讲的是java的实现。

首先去下载个rsslibj的包:

http://sourceforge.net/project/showfiles.php?group_id=71153

参考官方网站的例子程序

import com.rsslibj.elements.Channel;

public class Writer {

public static void main(String[] args)

throws InstantiationException, ClassNotFoundException,

IllegalAccessException {

Channel channel=new Channel();

channel.setDescription("This is my sample channel.");

channel.setLink("http://localhost/");

channel.setTitle("My Channel");

channel.setImage("http://localhost/",

"The Channel Image",

"http://localhost/foo.jpg");

channel.setTextInput("http://localhost/search",

"Search The Channel Image",

"The Channel Image",

"s");

channel.addItem("http://localhost/item1",

"The First Item covers details on the first item>",

"The First Item")

.setDcContributor("Joseph B. Ottinger");

channel.addItem("http://localhost/item2",

"The Second Item covers details on the second item",

"The Second Item")

.setDcCreator("Jason Bell");

System.out.println("The feed in RDF: "+channel.getFeed("rdf"));

}

}

开始怀疑中文会有问题(老外的软件),测试了一下居然很好,什么问题也没有。你要是熟悉rss文档格式,很容易编写一个标准的rss的writer出来。

参考:rsslibj的主页 http://enigmastation.com/rsslibj/

Hanic's Web Log : http://blog.csdn.net/hanic

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航