> >xml.sax.saxutils.escape(/data/[, /entities/]) > > > Escape '&', '<', and '>' in a string of data. > > > You can escape other strings of data by passing a dictionary as the > >optional /entities/ parameter. The keys and values must all be > >strings; each key will be replaced with its corresponding value. The > >characters '&', '<' and '>' are always escaped, even if /entities/ > >is provided. > > >Let us know if that doesn't do the trick. > > >DaveA
Thank you Dave It is working perfectly with the modifications you suggested. <code> def sc(adir): entities = {'&' : '&', '<' : '<', '>' : '>', '"' : '"', "'" : '''} import os,myfiles,xml.sax.saxutils dest=open('C:/scripts.html','w') s=myfiles.myfiles(adir) dest.write('<html>') for x in s: if os.path.isfile(x): sorce=open(x,'r') dest.write('<h1><font=Helvetica,fontsize=14>') dest.write(x) dest.write('</h1><pre>') for l in sorce: l=xml.sax.saxutils.escape(l,entities) dest.write('<font=Arial,fontsize=8>') dest.write(l) dest.write('<pre>') sorce.close() else:pass dest.write('</html>') dest.close()
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor