学以致用:写一个属于自己的Rss
2008-01-05 20:12:50 来源:WEB开发网首先去下载个rsslibj的包:[点击这里]
参考官方网站的例子程序
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出来。
更多精彩
赞助商链接