Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Encoding error (http://www.velocityreviews.com/forums/t319653-encoding-error.html)

Casey Kohrt 07-14-2003 02:56 PM

Encoding error
 
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)

Casey Kohrt
GIS Librarian
Iowa Geological Survey
109 Trowbridge Hall
Iowa City, Iowa 52242
319-335-1353
ckohrt@igsb.uiowa.edu



Alan Kennedy 07-14-2003 03:32 PM

Re: Encoding error
 
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


All times are GMT. The time now is 06:01 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.