ignoring chinese characters parsing xml file

Stefan Behnel stefan.behnel-n05pAM at web.de
Tue Oct 23 08:38:17 CEST 2007

Fabian López wrote:
> Thanks Mark, the code is like this. The attrib name is the problem:
> from lxml import etree
> context = etree.iterparse("file.xml")
> for action, elem in context:
>     if elem.tag == "weblog":
>         print action, elem.tag , elem.attrib["name"],elem.attrib["url"],

The problem is the print statement. Looks like your terminal encoding (that
Python needs to encode the unicode string to) can't handle these unicode


More information about the Python-list mailing list