服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

学以致用:写一个属于自己的rss

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

  首先去下载个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出来。






扫描关注微信公众号