主题:  使用JAVA rss4j包制作RSS文件

s22

职务:版主
等级:4
金币:10.0
发贴:1634
注册:2004/12/19 13:06:46
#12003/12/23 10:45:22
================================================
=下载:http://www.churchillobjects.com/soft/rss4j/rss4j092.jar
================================================
=浏览:http://www.churchillobjects.com/c/13005.html
================================================
=需求:http://xml.apache.org/xerces2-j/index.html
================================================
安装:1解压 rss4j092包,获得rss4j.jar拷贝到{your wwwrooo}/WEB-INF/lib/
2解压在xerces2-j下的zip包,把里面的几个JAR文件拷贝到{your wwwrooo}/WEB-INF/lib/

<cfscript>
doc=createObject("java","churchillobjects.rss4j.RssDocument");
doc.setVersion(doc.VERSION_10);

// create and add a new channel
channel =createObject("java","churchillobjects.rss4j.RssChannel"); 
channel.setChannelTitle("ChurchillObjects.com Features");
channel.setChannelLink("http://www.churchillobjects.com");
channel.setChannelDescription("Advanced Object-Oriented Developer Resource");
channel.setChannelUri("http://www.churchillobjects.com/rss/");
doc.addChannel(channel);

// create and add two items

item1 = createObject("java","churchillobjects.rss4j.RssChannelItem"); 
item1.setItemTitle("Networking Apps With Redenzvous");
item1.setItemLink("http://www.churchillobjects.com/c/11028.html");
item1.setItemDescription("Avoid the difficulties of internetworked applications with this fast, robust framework package.");
channel.addItem(item1);

item2 = createObject("java","churchillobjects.rss4j.RssChannelItem"); 
item2.setItemTitle("Secure Sockets with JSSE & OpenSSL");
item2.setItemLink("http://www.churchillobjects.com/c/11201.html");
item2.setItemDescription("Find out how to implement robust secure communnications between your clients and servers, including making your own certificate authority.");
channel.addItem(item2);

// create and add an image for the channel
img = createObject("java","churchillobjects.rss4j.RssChannelImage");
img.setImageLink("http://www.churchillobjects.com");
img.setImageUrl("http://www.churchillobjects.com/i/co.gif");
img.setImageTitle("ChurchillObjects.com");
channel.setChannelImage(img);
rfile=createObject("java","java.io.File");
rfile.init(JavaCast('string', "c:\rss.xml"));
RssGenerator=createObject("java","churchillobjects.rss4j.generator.RssGenerator");
</cfscript>
<cftry>
  <cfset RssGenerator.generateRss(doc, rfile)>
  成功
  <cfcatch type="any">
  出错
  </cfcatch>
</cftry>