注)Ver.0.72をPHP5.1.6の環境で動かしています。
MagpieRSSのrss_parse.inc内では、xml_set_element_handler関数を利用してXMLをパースしますが、どうやらRSS系については属性をうまく処理していないようです。対応できている属性は、rss要素のversion属性とchannel要素やitem要素rdf:aboutのみ。Atomではいろいろと対応しているようです。
enclosure要素から{url,length,type}を取得したかったので、feed_start_elementの中をいじることで無理やり対応させました。
Index: rss_parse.inc =================================================================== --- rss_parse.inc (revision XXXX) +++ rss_parse.inc (working copy) @@ -187,7 +187,13 @@ $this->current_item['about'] = $attrs['rdf:about']; } } - + // **** enclosure **** + elseif ( + $this->feed_type == RSS and + $el == 'enclosure' ) + { + $this->current_item['enclosure'] = $attrs; + } // if we're in the default namespace of an RSS feed, // record textinput or image fields elseif ( @@ -270,7 +276,6 @@ function feed_end_element ($p, $el) { $el = strtolower($el); - if ( $el == 'item' or $el == 'entry' ) { $this->items[] = $this->current_item;
今回はソースをいじって対応しましたが、いっそ別のライブラリを探したほうがいいのでしょうか?

