Write data to an xml file.

Posted by Bobby on Stack Overflow See other posts from Stack Overflow or by Bobby
Published on 2010-05-10T04:51:58Z Indexed on 2010/05/10 4:58 UTC
Read the original article Hit count: 431

Filed under:
|
|
|

My aim is to write an XML file with few tags whose values are the regional language. I'm using Python to do this and using IDLE(Pythong GUI) for programming.

While I try to write the words in an xmls file it gives the following error. UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)

For now, I'm not using any xml writer library instead I'm opening a file "test.xml" and writing the data into it. This error is encountered by the line: f.write("\t\" + data + "\"). If I replace the above write statement with print statement then it prints the data properly on Python Shell.

I'm reading the data from an excel file which is not in the UTF8,16, or 32 encoding formats. Its in some other format. cp1252 is reading the data properly.

Any help in getting this data writtent oan xml would be highly appreciated.

Thanks in advance. Bob

© Stack Overflow or respective owner

Related posts about write

Related posts about Xml