Encoding error

C

Casey Kohrt

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
(e-mail address removed)
 
A

Alan Kennedy

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top