XPathRecord

An XML to read-only Python objects library
Download

XPathRecord Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Creative Commons Att...
  • Price:
  • FREE
  • Publisher Name:
  • Corey Porter
  • Publisher web site:
  • http://gemcitysoftware.com

XPathRecord Tags


XPathRecord Description

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 xpathrecordclass 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, sysfor feed_url in sys.argv: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() Requirements: · Python


XPathRecord Related Software