XPathRecord 0.3

An XML to read-only Python objects library
XPathRecord is a software that seeks to take some of the grunt work out of transforming XML in to objects. Follows is a very brief example of an RSS parser.

import xpathrecord

class RSSPost(xpathrecord.XPathRecord):
title = xpathrecord.TextField('title/text()')
link = xpathrecord.TextField('link/text()')
pubdate = xpathrecord.DatetimeField('pubDate/text()',
'%a, %d %b %Y %H:%M:%S +0000')

def main():
import libxml2, urllib2, sys
for feed_url in sys.argv[1:]:
doc = urllib2.urlopen(feed_url).read()
dom = libxml2.parseMemory(doc, len(doc))
for post in RSSPost.records(dom, '//item'):
print 'Post:'
print ' title: %s' % post.title()
print ' link: %s' % post.link()
print ' date: %s' % post.pubdate()

if '__main__' == __name__:
main()

last updated on:
August 6th, 2009, 19:58 GMT
price:
FREE!
developed by:
Corey Porter
license type:
Creative Commons Attribution 
category:
ROOT \ Text Editing&Processing \ Markup

FREE!

In a hurry? Add it to your Download Basket!

user rating

UNRATED
0.0/5
 

0/5

Add your review!

SUBMIT