Skip to content

Instantly share code, notes, and snippets.

@lrei
Created September 22, 2014 18:40
Show Gist options
  • Save lrei/e59dc53426d37a6eb33a to your computer and use it in GitHub Desktop.
Save lrei/e59dc53426d37a6eb33a to your computer and use it in GitHub Desktop.
from xml.dom import minidom
xmlstr = """<item>
<category>Category1</category>
<category>Category2</category>
<category>Category3</category>
</item>"""
dom = minidom.parseString(xmlstr)
items = dom.getElementsByTagName('item')
for item in items:
cats = item.getElementsByTagName('category')
for c in cats:
print c.firstChild.data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment