Created
July 13, 2012 07:10
-
-
Save ohta-rh/3103295 to your computer and use it in GitHub Desktop.
Python XML parse sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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