[python] xml et encoding / bug !

xml et encoding / bug ! [python] - Python - Programmation

Marsh Posté le 23-11-2006 à 17:14:11    

salut,
j'ai un doc texte que je veux convertir en xml. j'utilise minidom, mais j'ai dans ce texte des caractères moches à savoir "ã". j'aimerais donc specifier qu'il s'agit d'un xml de sortie encode en ISO-8859-1, donc j'utilise :
 
return myDoc.toxml('iso-8859-1')
 
mais ca me pond une erreur :(
 

Code :
  1. ************************** TXTFILE **************************
  2. ./income/000701c70efd$5630c520$0600080a@thinkpadpato/in/nstdec_99999000003200619.nst/99999000003200619.nst.txt
  3. Exception in thread Thread-1:
  4. Traceback (most recent call last):
  5.   File "C:\Python24\lib\threading.py", line 442, in __bootstrap
  6.     self.run()
  7.   File "iaNistConv.py", line 96, in run
  8.     self.checkJobs()
  9.   File "iaNistConv.py", line 131, in checkJobs
  10.     xml_file = self.convertToXml(txt_file)
  11.   File "iaNistConv.py", line 190, in convertToXml
  12.     output_xml = my_xml.dumpAsXml()
  13.   File "iaNistConv.py", line 69, in dumpAsXml
  14.     return myDoc.toxml('iso-8859-1')
  15.   File "C:\Python24\Lib\site-packages\_xmlplus\dom\minidom.py", line 47, in toxml
  16.     return self.toprettyxml("", "", encoding)
  17.   File "C:\Python24\Lib\site-packages\_xmlplus\dom\minidom.py", line 59, in toprettyxml
  18.     self.writexml(writer, "", indent, newl, encoding)
  19.   File "C:\Python24\Lib\site-packages\_xmlplus\dom\minidom.py", line 1746, in writexml
  20.     node.writexml(writer, indent, addindent, newl)
  21.   File "C:\Python24\Lib\site-packages\_xmlplus\dom\minidom.py", line 821, in writexml
  22.     node.writexml(writer,indent+addindent,addindent,newl)
  23.   File "C:\Python24\Lib\site-packages\_xmlplus\dom\minidom.py", line 821, in writexml
  24.     node.writexml(writer,indent+addindent,addindent,newl)
  25.   File "C:\Python24\Lib\site-packages\_xmlplus\dom\minidom.py", line 821, in writexml
  26.     node.writexml(writer,indent+addindent,addindent,newl)
  27.   File "C:\Python24\Lib\site-packages\_xmlplus\dom\minidom.py", line 816, in writexml
  28.     _write_data(writer, attrs[a_name].value)
  29.   File "C:\Python24\Lib\site-packages\_xmlplus\dom\minidom.py", line 306, in _write_data
  30.     writer.write(data)
  31.   File "C:\Python24\lib\codecs.py", line 178, in write
  32.     data, consumed = self.encode(object, self.errors)
  33. UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 6: ordinal not in range(128)
  34. c:\IAFIS BRASIL\DEV>


 
help si qulequ'un a une idee ?

Reply

Marsh Posté le 23-11-2006 à 17:14:11   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed