Last active
November 3, 2015 00:47
-
-
Save srcreigh/9d32f34328eccaa0534f to your computer and use it in GitHub Desktop.
This file contains 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
from xml.dom import minidom | |
import json | |
xmldoc = minidom.parse('changelogs.xml') | |
items = [] | |
itemsxml = xmldoc.getElementsByTagName('string-array') | |
versions = itemsxml[0].getElementsByTagName('item') | |
dates = itemsxml[1].getElementsByTagName('item') | |
descs = itemsxml[2].getElementsByTagName('item') | |
def GetValue(thing): | |
return thing.firstChild.nodeValue | |
for i in range(0,len(versions)): | |
item = {} | |
item['version_name'] = GetValue(versions[i]) | |
item['release_date'] = GetValue(dates[i]) | |
changes = GetValue(descs[i]).split('\\n') | |
for j in range(0,len(changes)): | |
if j == 0: | |
changes[j] = changes[j][4:] | |
elif j == len(changes)-1: | |
changes[j] = changes[j][3:-1] | |
else: | |
changes[j] = changes[j][3:] | |
item['changes'] = changes | |
items.append(item) | |
print json.dumps(items[::-1], indent=4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment