W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2001

Re: getAttributeNode vs getAttributeNodeNS

From: Jonas Sicking <sicking@bigfoot.com>
Date: Wed, 14 Feb 2001 19:35:26 +0100
Message-ID: <00c901c096b4$e6246b40$5412a8c0@Milwork08>
To: <www-dom@w3.org>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:48 GMT