Skip to content

Instantly share code, notes, and snippets.

@jmitchell
Last active November 15, 2016 23:11
Show Gist options
  • Save jmitchell/6ba20ebf1201aa782eac42d67e8ce41a to your computer and use it in GitHub Desktop.
Save jmitchell/6ba20ebf1201aa782eac42d67e8ce41a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import xml.etree.ElementTree as ET
tree = ET.parse("senators_cfm.xml")
root = tree.getroot()
for member in root.findall("member"):
first_name = member.find("first_name").text
last_name = member.find("last_name").text
state = member.find("state").text
phone = member.find("phone").text
website = member.find("website").text
print "%s %s\t%s\tSenator\t%s\t%s" % (first_name, last_name, state, phone, website)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment