Created
April 10, 2014 10:02
-
-
Save voroninman/10363945 to your computer and use it in GitHub Desktop.
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
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