Ruby gem for parsing OMPL
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
Gemfile
LICENSE
README.md
Rakefile
opml-parser.gemspec

README.md

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