Skip to content

Instantly share code, notes, and snippets.

@voroninman
Created April 10, 2014 10:02
Show Gist options
  • Save voroninman/10363945 to your computer and use it in GitHub Desktop.
Save voroninman/10363945 to your computer and use it in GitHub Desktop.
import sys
import xml.etree.cElementTree as et
def main(file_path):
f = open(file_path, 'r')
iter = et.iterparse(f)
print '<html><meta charset="utf8">'
for event, elem in iter:
if elem.tag == 'offer':
children = dict((c.tag, c.text) for c in elem.getchildren())
print u'''
<ul>
<li>{0}</li>
<li>{1} {2}</li>
<li>{3}</li>
</ul>
'''.format(
children['url'],
children['price'],
children['currencyId'],
children['model']
)
if __name__ == '__main__':
main(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment