2004年03月10日 星期三 14:53
The xml file ChineseXML.xml in the Python code below has a lot of Chinese characters in it. And the first line of that xml file is: I tried to run the following code, but python says that it cannot recognize the encoding gb2312. What should I do? # -*- coding: cp936 -*- from xml.dom import minidom xmldoc = minidom.parse('ChineseXML.xml') print xmldoc.toxml() __________________________________ Do you Yahoo!? Yahoo! Search - Find what youre looking for faster http://search.yahoo.com
2004年03月10日 星期三 14:54
Have you installed unicode codec set for Chinese? http://cjkpython.i18n.org/ -----Original Message----- From: Anthony Liu [mailto:antonyliu2002 at yahoo.com] Sent: 2004年3月10日 14:53 To: pycn Subject: [python-chinese] Python's minidom does not support Chinese? The xml file ChineseXML.xml in the Python code below has a lot of Chinese characters in it. And the first line of that xml file is: I tried to run the following code, but python says that it cannot recognize the encoding gb2312. What should I do? # -*- coding: cp936 -*- from xml.dom import minidom xmldoc = minidom.parse('ChineseXML.xml') print xmldoc.toxml()
2004年03月10日 星期三 15:05
Hello Anthony, ºÃÏóÊÇûÓÐGB2312 µÄ±àÂëµÄ£¡ ¸Ä³Éutf-8 µÄXML Îĵµ°É£¡ === [ 14:53 ; 04-03-10 ] you wrote: AL> The xml file ChineseXML.xml in the Python code below AL> has a lot of Chinese characters in it. And the first AL> line of that xml file is: AL> AL> I tried to run the following code, but python says AL> that it cannot recognize the encoding gb2312. AL> What should I do? AL> # -*- coding: cp936 -*- AL> from xml.dom import minidom AL> xmldoc = minidom.parse('ChineseXML.xml') AL> print xmldoc.toxml() AL> __________________________________ AL> Do you Yahoo!? AL> Yahoo! Search - Find what youre looking for faster AL> http://search.yahoo.com === === === === === === === === === === -- Best regards, Zoom.Quiet /=======================================\ ]Time is unimportant, only life important![ \=======================================/
2004年03月10日 星期三 15:28
I tried UTF-8 and UTF-16, there is a little bit change in the error message. Now, python complains about the xml document when it hits the first Chinese character in the document and says that the xml document is not well-formed. Yes, I have installed the cjkcodecs. --- "Zoom.Quiet" <zoomq at infopro.cn> wrote: > Hello Anthony, > > 好象是没有GB2312 的编码的! > > 改成utf-8 的XML 文档吧! > === [ 14:53 ; 04-03-10 ] you wrote: > > AL> The xml file ChineseXML.xml in the Python code > below > AL> has a lot of Chinese characters in it. And the > first > AL> line of that xml file is: > > AL> > > AL> I tried to run the following code, but python > says > AL> that it cannot recognize the encoding gb2312. > > AL> What should I do? > > AL> # -*- coding: cp936 -*- > > AL> from xml.dom import minidom > AL> xmldoc = minidom.parse('ChineseXML.xml') > AL> print xmldoc.toxml() > > > AL> __________________________________ > AL> Do you Yahoo!? > AL> Yahoo! Search - Find what you抮e looking for > faster > AL> http://search.yahoo.com > > === === === === === === === === === === > > -- > Best regards, > Zoom.Quiet > > /=======================================\ > ]Time is unimportant, only life important![ > \=======================================/ > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese __________________________________ Do you Yahoo!? Yahoo! Search - Find what youre looking for faster http://search.yahoo.com
2004年03月10日 星期三 15:29
Yes, I have installed cjkcodecs. --- Jacob Fan <jacob at exoweb.net> wrote: > Have you installed unicode codec set for Chinese? > http://cjkpython.i18n.org/ > -----Original Message----- > From: Anthony Liu [mailto:antonyliu2002 at yahoo.com] > Sent: 2004年3月10日 14:53 > To: pycn > Subject: [python-chinese] Python's minidom does not > support Chinese? > > > The xml file ChineseXML.xml in the Python code below > has a lot of Chinese characters in it. And the > first > line of that xml file is: > > > > I tried to run the following code, but python says > that it cannot recognize the encoding gb2312. > > What should I do? > > # -*- coding: cp936 -*- > > from xml.dom import minidom > xmldoc = minidom.parse('ChineseXML.xml') > print xmldoc.toxml() > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese __________________________________ Do you Yahoo!? Yahoo! Search - Find what youre looking for faster http://search.yahoo.com
2004年03月11日 星期四 09:41
it seems that python's minidom xml parser does not support chinese. --- "Zoom.Quiet" <zoomq at infopro.cn> wrote: > Hello Anthony, > > 好象是没有GB2312 的编码的! > > 改成utf-8 的XML 文档吧! > === [ 14:53 ; 04-03-10 ] you wrote: > > AL> The xml file ChineseXML.xml in the Python code > below > AL> has a lot of Chinese characters in it. And the > first > AL> line of that xml file is: > > AL> > > AL> I tried to run the following code, but python > says > AL> that it cannot recognize the encoding gb2312. > > AL> What should I do? > > AL> # -*- coding: cp936 -*- > > AL> from xml.dom import minidom > AL> xmldoc = minidom.parse('ChineseXML.xml') > AL> print xmldoc.toxml() > > > AL> __________________________________ > AL> Do you Yahoo!? > AL> Yahoo! Search - Find what you抮e looking for > faster > AL> http://search.yahoo.com > > === === === === === === === === === === > > -- > Best regards, > Zoom.Quiet > > /=======================================\ > ]Time is unimportant, only life important![ > \=======================================/ > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese __________________________________ Do you Yahoo!? Yahoo! Search - Find what youre looking for faster http://search.yahoo.com
Zeuux © 2024
京ICP备05028076号