Skip to content

Instantly share code, notes, and snippets.

@zeha
Created December 5, 2013 08:21
Show Gist options
  • Save zeha/7801882 to your computer and use it in GitHub Desktop.
Save zeha/7801882 to your computer and use it in GitHub Desktop.
import codecs
import sys
from xml.dom.minidom import parse, parseString
def minimize(el):
attrs = []
for i in range(0, el.attributes.length):
attrs.append(el.attributes.item(i).name)
for attr in attrs:
if el.getAttribute(attr) == "" or el.getAttribute(attr) == "0":
el.removeAttribute(attr)
domIn = parse(sys.argv[1])
for el in domIn.getElementsByTagName("action"):
minimize(el)
for el in domIn.getElementsByTagName("field"):
minimize(el)
domIn.writexml(codecs.open(sys.argv[2], 'w', 'utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment