Skip to content

Instantly share code, notes, and snippets.

@ohta-rh
Created July 13, 2012 07:10
Show Gist options
  • Select an option

  • Save ohta-rh/3103295 to your computer and use it in GitHub Desktop.

Select an option

Save ohta-rh/3103295 to your computer and use it in GitHub Desktop.
Python XML parse sample
#coding: utf-8
from xml.etree.ElementTree import ElementTree
import urllib
url = "http://example.com/example.xml"
xml = ElementTree(file=urllib.urlopen(url))
for e in list(xml.getroot().getiterator()):
if e.tag != None and e.text != None :
print e.tag.encode("utf-8") + ":" + e.text.encode("utf-8")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment