Python论坛  - 讨论区

标题:[python-chinese] Python's minidom does not support Chinese?

2004年03月10日 星期三 14:53

Anthony Liu antonyliu2002 at yahoo.com
Wed Mar 10 14:53:17 HKT 2004

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 you’re looking for faster
http://search.yahoo.com


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年03月10日 星期三 14:54

Jacob Fan jacob at exoweb.net
Wed Mar 10 14:54:59 HKT 2004

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()



[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年03月10日 星期三 15:05

Zoom.Quiet zoomq at infopro.cn
Wed Mar 10 15:05:19 HKT 2004

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’re looking for faster
AL> http://search.yahoo.com

=== === === === === === === === === === 

-- 
Best regards,
 Zoom.Quiet                            

 /=======================================\
]Time is unimportant, only life important![
 \=======================================/



[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年03月10日 星期三 15:28

Anthony Liu antonyliu2002 at yahoo.com
Wed Mar 10 15:28:46 HKT 2004

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 you’re looking for faster
http://search.yahoo.com


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年03月10日 星期三 15:29

Anthony Liu antonyliu2002 at yahoo.com
Wed Mar 10 15:29:17 HKT 2004

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 you’re looking for faster
http://search.yahoo.com


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年03月11日 星期四 09:41

Anthony Liu antonyliu2002 at yahoo.com
Thu Mar 11 09:41:14 HKT 2004

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 you’re looking for faster
http://search.yahoo.com


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号