[XML-SIG] Re: [4suite] Attribute none object

Uche Ogbuji uche.ogbuji@fourthought.com
Fri, 04 Jan 2002 09:09:34 -0700

S=E9bastien Pierre wrote:
> Hi all,
> This may be a PyXML related issued, but as it is from 4DOM I
> post it on 4Suite also...
> Using PyXML 0.66, 4Suite 0.11, I do the following:
> a =3D node.getAttributeNS('','src'))
> print a
> a =3D node.attributes.getNamedItem('src')
> print a
> print a.nodeValue
> The first print does nothing (blank line), so obviously a is None
> The second print is:
> <Attribute Node at c62c8c: Name=3D"src",
> Value=3D"../Schemas/Planning-Preliminary.png">
> The third one generates an exception:
> AttributeError: 'None' object has no attribute 'nodeValue'
> So in this case a is an Attr at the second print and then
> becomes None at the following one... I'm puzzled.

It's an FAQ, but don't feel bad because no one has bothered to keep an
updated FAQ with answers  :-)

You need to use

getNamedItem('', 'src')

Remember that in PyXML 0.7 and 4Suite in CVS, you would have to use None
rather than '', or better yet, EMPTY_PREFIX

Uche Ogbuji                               Principal Consultant
uche.ogbuji@fourthought.com               +1 303 583 9900 x 101
Fourthought, Inc.                         http://Fourthought.com=20
4735 East Walnut St, Boulder, CO 80301-2537, USA
XML strategy, XML tools (http://4Suite.org), knowledge management