Encoding error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Casey Kohrt

    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.createEleme nt("eainfo")
    metadata.append Child(eainfo)
    overview = doc.createEleme nt("overview")
    eainfo.appendCh ild(overview)
    eaover = doc.createEleme nt("eaover")
    text = doc.createTextN ode(str(list[83]))
    eaover.appendCh ild(text)
    overview.append Child(eaover)

    Casey Kohrt
    GIS Librarian
    Iowa Geological Survey
    109 Trowbridge Hall
    Iowa City, Iowa 52242
    319-335-1353
    [email protected] wa.edu


  • Alan Kennedy

    #2
    Re: Encoding error

    Casey Kohrt wrote:
    [color=blue]
    > 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.createEleme nt("eainfo")
    > metadata.append Child(eainfo)
    > overview = doc.createEleme nt("overview")
    > eainfo.appendCh ild(overview)
    > eaover = doc.createEleme nt("eaover")
    > text = doc.createTextN ode(str(list[83]))
    > eaover.appendCh ild(text)
    > overview.append Child(eaover)[/color]

    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.documentEle ment
    eainfo = doc.createEleme nt("eainfo")
    metadata.append Child(eainfo)
    overview = doc.createEleme nt("overview")
    eainfo.appendCh ild(overview)
    eaover = doc.createEleme nt("eaover")
    text = doc.createTextN ode(chr(83))
    #text = doc.createTextN ode(' '*83) (?)
    eaover.appendCh ild(text)
    overview.append Child(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

    Comment

    Working...