Announcing xe and PyFeed, for XML and syndication feeds

S

Steve R. Hastings

xe.py is a Python module to make it very easy to work with XML. I have
attempted to make xe classes very Pythonic and intuitive. xe is intended
for working with structured XML, such as syndication feed files, but I
have added some support for unstructured XML as well.

Example:
import xe
bird = xe.TextElement("bird")
bird.attrs["type"] = "Norwegian Blue"
bird.text = "just resting"
print bird
cheese = xe.TextElement("cheese")
cheese.text = "a bit runny"
examples = xe.NestElement("examples")
examples.bird = bird
examples.cheese = cheese
print examples
<examples>
<bird type="Norwegian Blue">just resting</bird>
<cheese>a bit runny</cheese>
</examples>


PyFeed is a Python module package set with modules for working with
syndication feeds. These modules use the xe classes. PyFeed currently
includes modules for working with Atom feeds, RSS 2.0 feeds, OPML 1.0
files, and OPML files.

Example:
import feed.rss
channel = feed.rss.Channel()
lst_errors = []
channel.import_xml("http://www.planetpython.org/rss20.xml", lst_errors)
print len(lst_errors) or "No errors!" No errors!
print channel.title
print len(channel.items) 45
print channel.items[0].title.text Mike Fletcher: Minor TwistedSNMP release is up
item = channel.items[0]
print item.pub_date.text Thu, 23 Mar 2006 15:45:31 -0800
# note that the date printed with "-0800", my time zone ....
item.pub_date.update()
print item.pub_date
item.pub_date = "not a valid timestamp"
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python/xe.py", line 1327, in __setattr__
o.direct(value)
File "/usr/local/lib/python/xe.py", line 1148, in direct
raise ValueError, "value must be a valid timestamp string"
ValueError: value must be a valid timestamp string1136102483.0



If there is any interest in these modules, I'll probably put them on
Sourceforge.net and on the Cheese Shop someday. For now, they live on my
personal web space:

http://www.blarg.net/~steveha/xe.html

http://www.blarg.net/~steveha/pyfeed.html


I look forward to any feedback.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,247
Members
46,844
Latest member
JudyGvh32

Latest Threads

Top