Created
December 5, 2013 08:21
-
-
Save zeha/7801882 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 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