opml snippets

How to parse OPML with Ruby

Tagged opml, xml, parse, ruby  Languages ruby

This example demonstrates how to parse OPML with Ruby.

First install the gem.

gem install opml

Then run this code:

require 'pp'
require 'rubygems'
require 'opml'

opml = Opml.new(File.read('opml.xml'))
pp opml

opml.outlines[0].attributes['xml_url']
opml.outlines[0].attributes['html_url']
opml.outlines[0].attributes['title']