0.0
No commit activity in last 3 years
No release in over 3 years
A simple OPML parser
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.3
>= 0

Runtime

 Project Readme

OPML-Parser

Build Status Dependencies Status Gem Version opml-parser API Documentation

opml-parser is a simple Ruby gem that provides a module for parsing OPML.

Installation

gem install opml-parser

Usage

Import

subscriptions.xml

<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
    <head>
        <title>Foobar</title>
    </head>
    <body>
        <outline text="foo" title="bar" type="rss" xmlUrl="http://www.gilliek.ch/feeds" htmlUrl="http://www.gilliek.ch"/>
    </body>
</opml>
require 'opml-parser'
include OpmlParser

file = File.open("subscriptions.xml")
content = file.readlines.join("")

outlines = OpmlParser.import(content)

puts outlines[0].attributes

file.close

Output:

{:text=>"foo", :title=>"bar", :type=>"rss", :xmlUrl=>"http://www.gilliek.ch/feeds", :htmlUrl=>"http://www.gilliek.ch"}

Export

require 'opml-parser'
include OpmlParser

feed = {:text=>"foo", :title=>"bar", :type=>"rss",
        :xmlUrl=>"http://www.gilliek.ch/feeds",
        :htmlUrl=>"http://www.gilliek.ch"}

outline = OpmlParser::Outline.new(feed)

opml = OpmlParser.export([outline], "Foobar")

output = File.new("output.xml", "w")
output.puts(opml)
output.close

output.xml

<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
    <head>
        <title>Foobar</title>
    </head>
    <body>
        <outline text="foo" title="bar" type="rss" xmlUrl="http://www.gilliek.ch/feeds" htmlUrl="http://www.gilliek.ch"/>
    </body>
</opml>

Documentation

See http://doc.gw-computing.net/opml-parser