473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
ck****@igsb.uiowa.edu
Jul 18 '05 #1
1 1721
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
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ann | last post by:
Hi, Is there any way to Change encoding of Java Vm to ISO-8859-1? i am using Java vm along with an application called opencms. I get the following error message.. Error: the encoding of your...
14
by: Sebastian Meyer | last post by:
Hi newsgroup, i am trying to replace german special characters in strings like str = re.sub('ö', 'oe', str) When i work with this, i always get the message UniCode Error: ASCII decoding error...
1
by: Matt | last post by:
It has no error if I use <?xml version="1.0" encoding="utf-8" ?> in XML declaration. But if I use <?xml version="1.0" encoding="ISO-8859-1"?> It will produce error: The XML page cannot be...
48
by: Zenobia | last post by:
Recently I was editing a document in GoLive 6. I like GoLive because it has some nice features such as: * rewrite source code * check syntax * global search & replace (through several files at...
4
by: xmlguy | last post by:
XmlTextReader myXmlReader = new XmlTextReader(args); string en = myXmlReader.Encoding.EncodingName; //Console.WriteLine(x); Error: Unhandled Exception: System.NullReferenceException: Object...
6
by: jmgonet | last post by:
Hello everybody, I'm having troubles loading a Xml string encoded in UTF-8. If I try this code: ------------------------------ XmlDocument doc=new XmlDocument(); String s="<?xml...
8
by: Xarky | last post by:
Hi, I am downloading a GIF file(as a mail attachement) with this file format, Content-Transfer-Encoding: base64; Now I am writing the downloaded data to a file with this technique: ...
6
by: Danny | last post by:
I am working on a project in which a number of client applications will be posting xml documents as a byte array to an ASP.NET page on our web server. I am trying to simulate the process and run...
6
by: kath | last post by:
Hi all, Platform: winxp Version: Python 2.3 I have a task of reading files in a folder and creating an one excel file with sheets, one sheet per file, with sheet named...
2
by: =?Utf-8?B?bW9pdGFs?= | last post by:
I have a client application ( web service ) write in vs2005 consuming an external web service with WSE 2.0 (x509). The response is in hebrew ( windows-1255 ). In the Trace files I see the hebrew...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.