Skip to main content

Lightweight OPML parsing.

Project description

Date:
2007-03-20 08:30:21 -0700 (Tue, 20 Mar 2007)
Version:
5612
Author:

Nathan R. Yergler <nathan@yergler.net>

Organization:
Creative Commons

opml provides simple support for reading OPML files. OPML is an XML-based format for describing outlines and is often used as an interchange format for subscription lists. This package is intended as a light-weight, permissive parser. It does very little validation of the incoming OPML.

Installation

The Python OPML package and its dependencies may be installed using easy_install (recommended)

$ easy_install opml

or by using the standard distutils setup.py:

$ python setup.py install

If installing using setup.py, lxml will also need to be installed. easy_install will manage this for you.

Usage

opml can parse OPML from a URI or from a local string. For example, to parse an example from the OPML validator:

>>> import opml
>>> outline = opml.parse(
... 'http://hosting.opml.org/dave/validatorTests/clean/subscriptionList.opml')

Elements in the OPML header can be accessed as attributes:

>>> outline.title
'mySubscriptions.opml'
>>> outline.ownerName
'Dave Winer'
>>> outline.ownerEmail
'dave@scripting.com'

Items in an OPML outline are stored in <outline> elements; these are accessible via the standard Python sequence operators:

>>> len(outline)
13
>>> outline[0]
<opml.OutlineElement object at ...>

An OutlineElement object exposes the attributes associated with the element as properties:

>>> outline[0].text
'CNET News.com'
>>> outline[0].type
'rss'

outline elements may contain other outline elements:

>>> len(outline[0])
0

When parsing a feed with nested items, the sub-items are accessible using the standard Python sequence operators:

>>> nested = \
... opml.parse('http://hosting.opml.org/dave/spec/placesLived.opml')
>>> len(nested[0])
6
>>> nested[0][0].text
'Boston'
>>> len(nested[0][0])
2
>>> nested[0][0][0].text
'Cambridge'

Download

Project details


Release history Release notifications | RSS feed

This version

0.5

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opml-0.5.tar.gz (4.9 kB view hashes)

Uploaded Source

Built Distribution

opml-0.5-py2.5.egg (5.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page