Skip to content

Instantly share code, notes, and snippets.

@kathawala
Created December 12, 2014 00:46
Show Gist options
  • Save kathawala/0a195915c2008875359d to your computer and use it in GitHub Desktop.
Save kathawala/0a195915c2008875359d to your computer and use it in GitHub Desktop.
A simple parser for GMail's Atom feed xml. Prints out the Title and Summary and Email address of sender
import xml.etree.ElementTree as etree
tree = etree.parse('/home/farhan/bin/email.xml')
root = tree.getroot()
for entry in root.iter('{http://purl.org/atom/ns#}entry'):
for title in entry.findall('{http://purl.org/atom/ns#}title'):
print ('TITLE: ', title.text)
for author in entry.findall('{http://purl.org/atom/ns#}author'):
for email in author.findall('{http://purl.org/atom/ns#}email'):
print ('FROM: ', email.text)
for summary in entry.findall('{http://purl.org/atom/ns#}summary'):
print (summary.text[0:80], '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment