lmlx & & caracter
Stefan Behnel
stefan_ml at behnel.de
Tue Oct 27 06:06:00 EDT 2009
Toff, 27.10.2009 10:14:
> o = open("output.txt","w")
> data = open(filename).read()
> o.write( re.sub('&(?!amp;|quot;|nbsp;|gt;|lt;|laquo;|
> raquo;|copy;|reg;|bul;|rsquo;)', '&', data) )
> o.close()
> shutil.move
> ("output.txt",filename)
> xml = etree.parse(filename)
> xml = ET.parse(filename)
Absolutely no reason to write a file here. Use ET.fromstring().
And, just to repeat my question in other words: can't you just fix the
'XML' file before hand? I.e. is it a broken XML file coming from an outside
source that you cannot control, or did you create it yourself?
Stefan
More information about the Python-list
mailing list