RSS4j 0.92 anchor.png Edit

  • ライブラリのインストール

以下のサイトよりライブラリをダウンロード。
http://www.churchillobjects.com/c/13005.html

# cd /usr/local/arch
# wget http://www.churchillobjects.com/soft/rss4j/rss4j092.jar
# cd ../src
# jar xvf ../arch/rss4j092.jar
# cp rss4j092/lib/rss4j.jar /home/test/WEB-INF/lib
# cd /home/test/src/com/domain/test
# vi RssTest.java
  • サンプルソース
package com.domain.test;
import java.net.URL;
import java.util.Enumeration;
import churchillobjects.rss4j.RssChannel;
import churchillobjects.rss4j.RssChannelItem;
import churchillobjects.rss4j.RssDocument;
import churchillobjects.rss4j.parser.RssParser;
public class RssTest{
  public static void main(String args[])
   throws Exception{
    String url=null;
    try{
      if(args[0]!=null)url=args[0];
      URL u=new URL(url);
      RssDocument rss=RssParser.parseRss(u.openConnection().getInputStream());
      Enumeration e=rss.channels();
      while(e.hasMoreElements()){
        RssChannel rc=(RssChannel)e.nextElement();
        Enumeration items=rc.items();
        System.out.println(rc.getChannelTitle());
        System.out.println(rc.getChannelLink());
        System.out.println(rc.getChannelDescription());
        while(items.hasMoreElements()){
          RssChannelItem item=(RssChannelItem)items.nextElement();
          System.out.println(item.getItemTitle());
          System.out.println(item.getItemLink());
          System.out.println(item.getItemDescription());
        }
      }
    }
    catch(Exception e){
      e.printStackTrace();
    }
  }
}
# java com.domain.test.RssTest \
> http://news.goo.ne.jp/news/rss/topics/chumoku/index.rdf

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   ページ新規作成 全ページ一覧 単語検索 最新ページの一覧   ヘルプ   最新ページのRSS 1.0 最新ページのRSS 2.0 最新ページのRSS Atom
Counter: 638, today: 1, yesterday: 3
最終更新: 2008-11-26 (水) 02:07:46 (JST) (1272d) by aqua
オススメ

おすすめ
カレンダ
前月2012年 5月翌月
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
<今日>
ログイン
ユーザ名:

パスワード:



パスワード紛失

新規登録
天気予報

資料提供天気予報コム
アクセスカウンタ
今日 : 161161161
昨日 : 577577577
総計 : 363715363715363715363715363715363715