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 <bird type="Norwegian Blue">just resting</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) <feed.rss.Channel object at 0x77d0c18c> >>> print len(lst_errors) or "No errors!" No errors! >>> print channel.title <title>Unofficial Planet Python</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() <feed.rss.PubDate object at 0x778fed4c> >>> print item.pub_date <pubDate>Thu, 23 Mar 2006 17:15:55 -0800</pubDate> >>> 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 string >>> item.pub_date = "01 Jan 2006 08:01:23 GMT" >>> print item.pub_date.text Sun, 01 Jan 2006 00:01:23 -0800 >>> print item.pub_date.tf 1136102483.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. -- Steve R. Hastings "Vita est" [EMAIL PROTECTED] http://www.blarg.net/~steveha -- http://mail.python.org/mailman/listinfo/python-list