Skip to content

Instantly share code, notes, and snippets.

@JEuler
Created May 26, 2020 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JEuler/a72d744806ef50ece9eae033b7ba0947 to your computer and use it in GitHub Desktop.
Save JEuler/a72d744806ef50ece9eae033b7ba0947 to your computer and use it in GitHub Desktop.
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