XML DOM Attr Object

Attr Object

The Attr object represents the attributes of the Element object. The permissible values of attributes are usually defined in the 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. For many properties of Node objects, it will return null.

Attributes of the Attr object

Attribute Description
baseURI Returns the absolute base URI of the attribute.
isId Returns true if the attribute is of type id, otherwise returns false.
localName Returns the local part of the attribute name.
name Returns the name of the attribute.
namespaceURI Returns the namespace URI of the attribute.
nodeName Returns the name of the node, depending on its type.
nodeType Returns the type of the node.
nodeValue Set or return the value of the node, depending on its type.
ownerDocument Returns the root element (document object) of the attribute.
ownerElement Returns the element node to which the attribute is attached.
prefix Set or return the namespace prefix of the attribute.
schemaTypeInfo Returns the type information associated with the attribute.
specified

Returns true if the attribute value is set in the document;

Returns false if the attribute value is the default value in the DTD/Schema.

textContent Set or return the text content of the attribute.
value Set or return the value of the attribute.