<br><br><div><span class="gmail_quote">On 3/7/06, <b class="gmail_sendername">Fredrik Lundh</b> <<a href="mailto:fredrik@pythonware.com">fredrik@pythonware.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Abhimanyu Seth wrote:<br><br>> Sorry, my mistake. The file was not saved as utf-8. Saving it as utf-8<br>> solves my problems.<br>> >> f = codecs.open ("c:/test.txt", "r", "utf-8")
<br>> >> dom = minidom.parseString (codecs.encode (f.read(), "utf-8"))<br>><br>> However, I still need to encode the string returned by f.read () before<br>> passing it to parseString. Otherwise I get an exception.
<br><br>if the file contains UTF-8 data,<br><br> dom = minidom.parse("c:/test.txt")<br><br>should be exactly equivalent to your recoding solution. if it isn't, post a<br>copy of the sample file.<br><br>(if you've double-checked, and are 100% certain that it's not your editor
<br>or your environment that's playing tricks with you, you can also report this<br>over here:<br><br> <a href="http://sourceforge.net/tracker/?group_id=5470&atid=105470">http://sourceforge.net/tracker/?group_id=5470&atid=105470
</a><br><br>)<br><br></F><br><br><br><br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote></div><br>Hey thanks! yup, minidom.parse
() works just fine.<br><br>But for writexml(), I still need to use codecs.open("c:/test.txt", "w", "utf-8"). Is this a bug in writexml() ?<br clear="all"><br>-- <br>Regards,<br>Abhimanyu