In effetti ho bisogno di qualcosa di più robusto, ho creato questo: #!/usr/bin/python
import xml.etree.cElementTree as ET import string import sys infile = open(sys.argv[1], 'r') resources = ET.Element("resorurces") for line in infile.readlines(): if line.strip(): name, value = [ word.strip() for word in line.split("=",1) ] string = ET.SubElement(resources,"string") string.set("name", name) string.text = value infile.close() tree = ET.ElementTree(resources) tree.write(sys.argv[2]) ma non va... 2014-02-24 21:12 GMT+01:00 Diego Barrera <diegonebarr...@yahoo.it>: > On 24/02/2014 20:48, Dante Loi wrote: > > > #!/usr/bin/python > import stringimport sys > infile = open(sys.argv[1], 'r') outfile = open(sys.argv[2], 'w') > outfile.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n") > for line in infile.readlines(): > if line.strip(): > name, value = [ word.strip() for word in line.split("=",1) ] > outfile.write("\t<string name=\"" + name + "\">" + value + > "</string>\n") > outfile.write("</resources>") > infile.close()outfile.close() > > se volete proporre qualche miglioria è ben'accetta comunque funziona alla > perfezione! > > Per l'output puoi dare un'occhiata a format: > > http://docs.python.org/2.7/library/stdtypes.html?highlight=format#str.format > > Ciao > diego > > _______________________________________________ > Python mailing list > Python@lists.python.it > http://lists.python.it/mailman/listinfo/python > >
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python