[XML-SIG] I am stuck: 4DOM / utf-8

Horst Eyermann Horst Eyermann <horst@freedict.de>
Mon, 06 Aug 2001 07:36:13 -0000 (/etc/localtime


I am fairly new to python and XML, so I wish to apologise, if things should
have been obvious. - if this is the wrong place to ask, please point me to the
correct place.

I converted a XML file encoded in utf-8 into a DOM structure (PyXML-0.6.5).
Then I try to split the document into smaller subparts and store the parts into
a database, and display them with tkinter.
For extraction of XML from the DOM, the best function I found was PrettyPrint,
which unfortunately does not support direct assining to a string. So I followed
the examples utilizing the StringIO library. However, every time I try to
access the stream, I get an error (see below).
What should I do?


Thank you,

Horst



here the code snippet:

        print 2
        stream = StringIO()
        ext.PrettyPrint(value, stream=stream)
        stream.seek(0)
        text = load(stream)
        stream.close()
        

and here the error message:

2
Traceback (most recent call last):
  File "Imexport.py", line 68, in ?
    result = test.getElement()
  File "Imexport.py", line 48, in getElement
    stream.seek(0)
  File "/usr/local/lib/python2.1/StringIO.py", line 62, in seek
    self.buf += ''.join(self.buflist)
UnicodeError: ASCII decoding error: ordinal not in range(128)