L'interface Attr représente un attribut au sein d'un objet Element.

<element attribut="valeur"/>

Un attribut est composé d'un nom et d'une valeur. Si une définition de type de document ou un schéma existe, les caractéristiques de l'attribut y sont définies, en l'occurrence, le nom de l'attribut, les valeurs permises ou le type de valeurs (ex.: CDATA, ENTITY, ID, NMTOKEN, etc.) et l'élément auquel il est associé, ainsi que s'il doit être requis (#REQUIRED), implicite (#IMPLIED) ou fixe (#FIXED ["valeur par défaut"]).

<!ATTLIST element attribut CDATA #REQUIRED>

L'interface Attr étend l'interface Node. Ainsi, les champs et méthodes de l'interface Node sont tous disponibles à partir d'un attribut.

Champ
Description
Les champs hérités de l'interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE,
DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE,
DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS,
DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING,
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC,
DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE,
ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE,
PROCESSING_INSTRUCTION_NODE, TEXT_NODE
Méthode
Description
String getName()
retourne le nom de l'attribut.
Element getOwnerElement()
retourne l'élément auquel l'attribut est rattaché.
TypeInfo getSchemaTypeInfo()
retourne le type associé à l'attribut.
boolean getSpecified()
indique si l'attribut avait (true) ou n'avait pas (false) explicitement donné une valeur dans le document.
String getValue()
retourne la valeur de l'attribut.
boolean isId()
indique si l'attribut est (true) ou n'est pas (false) un attribut du type ID.
void setValue(String valeur)
fixe la valeur de l'attribut avec la valeur fournie.
Les méthodes héritées de l'interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI,
getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName,
getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue,
getOwnerDocument, getParentNode, getPrefix, getPreviousSibling,
getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore,
isDefaultNamespace, isEqualNode, isSameNode, isSupported,
lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild,
setNodeValue, setPrefix, setTextContent, setUserData