Parsing non utf-8 encoding XML in Python
"Xinzhi Zhao" <[email protected]> Fri, 12 Dec 2003 09:09:20 +0000
| Newsgroups | gmane.comp.web.zope.parsed-xml |
|---|---|
| Message-ID | <[email protected]> |
--===============0150146390== Content-Type: text/html <html><div style='background-color:'><DIV class=RTE>Hi,</DIV> <DIV class=RTE>My XML files have to use other encoding, i.e. 'gb2312', which is different from the default one 'utf-8'.</DIV> <DIV class=RTE>When I was using the package from 4DOM(pyxml.souceforge.net) to parse my XML files,errors occured. The package for parsing XML only supports encoding 'utf-8', right?</DIV> <DIV class=RTE> </DIV> <DIV class=RTE>Is there any way to solve my problem? And how shall I do it?</DIV> <DIV class=RTE> </DIV> <DIV class=RTE>-------------------------------------------------------------------------------</DIV> <DIV class=RTE>-- My XML file give below</DIV> <DIV class=RTE>--</DIV> <DIV class=RTE> </DIV> <DIV class=RTE><?xml version = "1.0" encoding = "gb2312" ?></DIV> <DIV class=RTE> </DIV> <DIV class=RTE><!-- This is my example. --></DIV> <DIV class=RTE> </DIV> <DIV class=RTE><article></DIV> <DIV class=RTE> </DIV> <DIV class=RTE><title> ¼òµ¥µÄ XML</title></DIV> <DIV class=RTE> </DIV> <DIV class=RTE><data>December 12, 2003</data></DIV> <DIV class=RTE> </DIV> <DIV class=RTE><author></DIV> <DIV class=RTE> <name>Xinzhi Zhao</name></DIV> <DIV class=RTE></author></DIV> <DIV class=RTE> </DIV> <DIV class=RTE><summary>Parsing XML</summary></DIV> <DIV class=RTE> </DIV> <DIV class=RTE><content>This XML include other encoding and it's runnable in IE6. However,parsing it in Python by DOM or SAX will be failed.How shall I do it?</DIV> <DIV class=RTE></content></DIV> <DIV class=RTE> </DIV> <DIV class=RTE></article></DIV> <DIV class=RTE> </DIV> <DIV class=RTE>--------------------------------------------------------------------------------</DIV> <DIV class=RTE> </DIV> <DIV class=RTE> </DIV> <DIV class=RTE>I look forward to hearing from you.</DIV> <DIV class=RTE> </DIV> <DIV class=RTE>Sincerely, </DIV> <DIV class=RTE>Xinzhi Zhao</DIV></div><br clear=all><hr>Add photos to your messages with <a href="http://g.msn.com/8HMBEN/2749??PS=">MSN 8. </a> Get 2 months FREE*.</html> --===============0150146390== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Parsed-XML-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/parsed-xml-dev --===============0150146390==--