DOMをアクセスする。
#!/usr/bin/ruby -Ku require "rexml/document" doc = REXML::Document.new File.open("./foo.atom") doc.root.each_element('/feed/entry'){|entry| #DocumentクラスからElementクラスへ変更しxpathに合致するElementクラスで繰り返す。 entry.each_element('link'){|link| puts link.attributes.get_attribute('href') #Attributeクラスに変更し、アトリビュートを取る } }
参考
http://pub.cozmixng.org/~kou/rexml-doc-ja/
Documentクラスのrootメソッドを発見するのにまず苦労した。