Encoding error

Alan Kennedy alanmk at hotmail.com
Mon Jul 14 11:32:57 EDT 2003


Casey Kohrt wrote:
 
> I get the following error for the list item below.  I know I have to
> encode it, but am unsure how or where to write that in.  I am new to
> python and have had good luck thus far.  Any help is greatly
> apprecieated.  I am not on the list, so a response to me is
> appreciated.
> 
> UnicodeError: ASCII encoding error: ordinal not in range(128)
> 
>     eainfo = doc.createElement("eainfo")
>     metadata.appendChild(eainfo)
>     overview = doc.createElement("overview")
>     eainfo.appendChild(overview)
>     eaover = doc.createElement("eaover")
>     text = doc.createTextNode(str(list[83]))
>     eaover.appendChild(text)
>     overview.appendChild(eaover)

Hmm, the code that you posted has several errors, and doesn't run.
You'll find it much easier to get help if you post instances of
running code that is giving you a problem. Also, a description of what
you're trying to achieve would be most helpful.

Here is a version of your code where I have fixed the errors, which
may or may not do something related to what you want.

#=======================================
import xml.dom.minidom

doc = xml.dom.minidom.parseString('<metadata/>')
metadata = doc.documentElement
eainfo = doc.createElement("eainfo") 
metadata.appendChild(eainfo) 
overview = doc.createElement("overview") 
eainfo.appendChild(overview) 
eaover = doc.createElement("eaover") 
text = doc.createTextNode(chr(83)) 
#text = doc.createTextNode(' '*83) (?)
eaover.appendChild(text) 
overview.appendChild(eaover)
print doc.toxml()
#=======================================

If I haven't even come close, then you really need to post actual
running code that you're using, and tell us where it's going wrong for
you.

HTH,

-- 
alan kennedy
-----------------------------------------------------
check http headers here: http://xhaus.com/headers
email alan:              http://xhaus.com/mailto/alan




More information about the Python-list mailing list