A simple regular expression might be sufficient in this case:
import re
f = open('your_file.xml')
try:
xml = f.read()
xml_with_trim = re.sub(r'(CDATA\[)([A-Z_]+)(\]\])', r'\1TRIM(\2)\3', xml)
print xml_with_trim
finally:
f.close()
The column name is matched using '[A-Z_]+' regex
i.e., one or more capital letters or '_'
. See documentation for the re module.
J.F. Sebastian
2009-12-12 08:33:55