XML DOM - AttrObject


Attr object

The Attr object represents an attribute of an Element object. The allowed values for attributes are usually defined in a DTD.

Since the Attr object is also a node, it inherits the properties and methods of the Node object. However, an attribute cannot have a parent node, and attributes are not considered child nodes of an element, so many Node properties will return null.

Attr Object Properties

Property Description
baseURI Returns the absolute base URI of the attribute.
isId Returns true if the attribute is of ID type, 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 Sets or returns the value of a node, depending on its type.
ownerDocument Returns the root element (document object) to which the attribute belongs.
ownerElement Returns the element node to which the attribute is attached.
prefix Sets or returns the namespace prefix of an attribute.
schemaTypeInfo Returns the type information associated with the property.
specified Returns true if the attribute value is set in the document, or false if its default value is set in the DTD/Schema.
textContent Sets or returns the text content of the attribute.
value Sets or returns the value of the attribute.

other extensions