Re: getAttributeNode vs getAttributeNodeNS

Paolo Casarini wrote:

> With an xml element like this:
>
> <TEST xmlns:pippo="urn:ex.ex.ex" FOO="bar" pippo:CIPPO="lippo" />
>
> if I call on the TEST element object the method getAttributeNode("FOO") I
> get the attribute object of FOO, if I call the
> getAttributeNodeNS("urn:ex.ex.ex","CIPPO") I get the attribute object of
> CIPPO,
> but if I call getAttributeNode("CIPPO") I should get CIPPO Attribute
> Object or NULL?

It should return NULL. Consider the following example:

<FOO xmlns:a="urn:a" bar="hello" a:bar="world">

in this case it is quite obvious that getAttributeNode("bar") should return
the bar="hello" node.

Note that namespaces on attributes behave differently then namespaces on
elements. If an attribute dosn't have a namespace it dosn't belong to the
default namespace, rather it belongs to the element and have a NULL
namespace (or is it "").

/ Jonas Sicking

Received on Wednesday, 14 February 2001 13:35:02 UTC