[XML-SIG] Node as Element?
Ian Sparks
ians@etrials.com
Thu, 20 Dec 2001 11:52:08 -0500
You were correct (thanks also to Rich and Alexandre).
Pesky WhiteSpace!
I think there's a setting for the DOM to filter this out when it is parsed
into the DOM?
Thanks.
- Ian Sparks.
-----Original Message-----
From: Fred L. Drake, Jr. [mailto:fdrake@acm.org]
Sent: Thursday, December 20, 2001 11:28 AM
To: Ian Sparks
Cc: 'xml-sig@python.org'
Subject: Re: [XML-SIG] Node as Element?
Ian Sparks writes:
> for x in y.childNodes:
> if x.getAttributeNS('','attribute_name') == 'foo':
> do_something...
>
> I get an error.
I'm going to guess that you're getting an AttributeError, and that x
is *not* an Element node, but a Text node that contains whitespace
from between elements. You should be able to use this:
for x in y.childNodes:
if (x.nodeType == Node.ELEMENT_NODE
and x.getAttributeNS('','attribute_name') == 'foo'):
do_something...
....snipped...