[XML-SIG] setAttribute DOM question-newbie

Guy Robinson ohbehave@ihug.co.nz
Thu, 15 Nov 2001 22:06:36 +1300


Hello Alexandre,

thanks for replying, Just this minute worked it out. The problem was the  my
list row contains numbers and text. eg. (1, 'Expat', 'an XML parser')

working code:

    for row in DbRec:
        new_elem = doc.createElement( 'ITEM')
        for i in range(len(QryAttrName)):
            s = row[i]
            if type(s) != type(""):
                s = `s`
            new_elem.setAttribute(QryAttrName[i], s)
        doc_elem.appendChild(new_elem)

----- Original Message -----
From: "Alexandre Fayolle" <Alexandre.Fayolle@logilab.fr>
To: "Guy Robinson" <ohbehave@ihug.co.nz>
Cc: <xml-sig@python.org>
Sent: Thursday, November 15, 2001 9:18 PM
Subject: Re: [XML-SIG] setAttribute DOM question-newbie


> On Thu, 15 Nov 2001, Guy Robinson wrote:
>
> > Hello,
> >
> > Trying to create a ODBC table -> xml ->(eventually) 4SS script and
having
> > the following problem with setattribute. I would like each field value
to be
> > an elements attribute but I can't get
new_elem.setAttribute(QryAttrName[i]
> > ,row[i] ) to work .I can't see
> > what's wrong with it (see complete code below). The traceback is:
>
> Could you add a print statement and tell us what the value of
> QryAttrName[i] is when the exception is generated ?
>
> Alexandre Fayolle
> --
> LOGILAB, Paris (France).
> http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org
> Narval, the first software agent available as free software (GPL).
>
>
> _______________________________________________
> XML-SIG maillist  -  XML-SIG@python.org
> http://mail.python.org/mailman/listinfo/xml-sig
>