All pastes #19754 Raw Edit

Parsing RSS in pytho

public python v1 · immutable
#19754 ·published 2005-08-10 21:20 UTC
rendered paste body
import urllib2import xml.dom.minidomurl = "http://backends.barrapunto.com/barrapunto.rss"content = urllib2.urlopen(url).read()document = xml.dom.minidom.parseString(content)for item_i, item_node in enumerate(document.getElementsByTagName("item")):    title_node = item_node.getElementsByTagName("title")[0]    link_node = item_node.getElementsByTagName("link")[0]    print "**",item_i, title_node.childNodes[0].nodeValue    print "    ",link_node.childNodes[0].nodeValue