Encoding error

Discussion in 'Python' started by Casey Kohrt, Jul 14, 2003.

  1. Casey Kohrt

    Casey Kohrt Guest

    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
    Casey Kohrt, Jul 14, 2003
    #1
    1. Advertising

  2. Casey Kohrt

    Alan Kennedy Guest

    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
    Alan Kennedy, Jul 14, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hardy Wang

    Encoding.Default and Encoding.UTF8

    Hardy Wang, Jun 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    18,805
    Jon Skeet [C# MVP]
    Jun 9, 2004
  2. Lars Netzel

    Error with.. "Transfer-encoding:..."

    Lars Netzel, Dec 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    397
    Johann MacDonagh
    Dec 5, 2004
  3. Replies:
    1
    Views:
    23,320
    Real Gagnon
    Oct 8, 2004
  4. Replies:
    0
    Views:
    3,377
  5. Replies:
    2
    Views:
    356
Loading...

Share This Page