Created
May 26, 2020 16:08
-
-
Save JEuler/a72d744806ef50ece9eae033b7ba0947 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 json | |
import stringcase | |
from xml.dom import minidom | |
xmldoc = minidom.parse('strings.xml') | |
itemlist = xmldoc.getElementsByTagName('string') | |
with open('strings.json', 'w', encoding='utf8') as out_file: | |
out_file.write('{') | |
for s in itemlist: | |
if (s.firstChild != None): | |
out_file.write('"') | |
out_file.write(stringcase.camelcase(s.getAttribute("name"))) | |
out_file.write('"') | |
out_file.write(": ") | |
out_file.write('"') | |
out_file.write((s.firstChild.data)) | |
out_file.write('"') | |
out_file.write(',') | |
out_file.write('\n') | |
else: | |
out_file.write('') | |
out_file.write('}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment