XML DOM Attr Object

The Attr object represents the attributes of the Element object.

Attr object

The Attr object represents the attributes of the Element object. The permissible values of the attributes are usually defined in DTD.

Since the Attr object is also a node, it inherits the properties and methods of the Node object. However, attributes cannot have a parent node, and attributes are not considered to be child nodes of elements, so for many properties of Node objects, null will be returned.

Properties of the Attr object

Attribute Description IE F O W3C
baseURI Return the absolute base URI of the attribute. No 1 No Yes
isId If the attribute is of type id, return true, otherwise return false. No No No Yes
localName Return the local part of the attribute name. No 1 9 Yes
name Return the name of the attribute. 5 1 9 Yes
namespaceURI Return the namespace URI of the attribute. No 1 9 Yes
nodeName Return the name of the node, depending on its type. 5 1 9 Yes
nodeType Return the type of the node. 5 1 9 Yes
nodeValue Set or return the value of the node, depending on its type. 5 1 9 Yes
ownerDocument Return the root element (document object) that the attribute belongs to. 5 1 9 Yes
ownerElement Return the element node that the attribute is attached to. No 1 9 Yes
prefix Set or return the namespace prefix of the attribute. No 1 9 Yes
schemaTypeInfo Returns type information associated with the attribute. No No No Yes
specified Returns true if the attribute value is set in the document, otherwise returns false if its default value is set in DTD/Schema. 5 1 9 Yes
textContent Sets or returns the text content of the attribute. No 1 9 Yes
text Returns the text of the attribute. IE-only. 5 No No No
value Sets or returns the value of the attribute. 5 1 9 Yes
xml Returns the XML of the attribute. IE-only. 5 No No No