今日も元気にテクニカル

技術情報書きたいけど本ブログに書きたくないからこんな名前になりました。

REXMLの利用

前記のnewsing取得スクリプトを利用して以下のようなXMLを作成してみた。

<?xml version="1.0" encoding="Shift-JIS" standalone="yes"?>
<items>
  <item>
    <url>http://newsing.jp/entry?url=headlines.yahoo.co.jp%2Fhl%3Fa%3D20070528-00000001-imp-sci</url>
    <title>東芝、「ぷよぷよ」もできる「gigabeat V」</title>
    <main_text></main_text>
    <picker>aplin</picker>
    <picktime>2007-05-29 01:04:32</picktime>
    <picker_eval>支持しない</picker_eval>
    <picker_com>gigabeatでぷよぷよをする意味など全くない。</picker_com>
    <pt>31</pt>
    <comments>
      <comment>
        <commenter>tera</commenter>
        <comtime>2007/05/29 02:45</comtime>
        <com_eval></com_eval>
        <com_text>Sの後継機出ないのかなぁ。</com_text>
        <nicecomment>0</nicecomment>
      </comment>
      <comment>
        <commenter>phantazy</commenter>
        <comtime>2007/05/29 10:32</comtime>
        <com_eval></com_eval>
        <com_text>ぷよぷよするな〜。</com_text>
        <nicecomment>0</nicecomment>
      </comment>
    </comments>
  </item>
  <item>
    (中略)
  </item>
</items>

これをREXMLを使ってパースする。

http://www-06.ibm.com/jp/developerworks/xml/020607/j_x-matters18.html
REXML : Rubyで実装されたXMLパーサ (REXML - MemoWiki)
REXML API document (ja)
REXML であそぶ
REXMLについて
lists.ruby-lang.org Mailing Lists
REXML:RubyによるXML処理 (1/3):CodeZine
RubyでXML操作 | Netsphere Laboratories