# Element

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Inherited Constants](https://developer.android.com/reference/org/w3c/dom/Element#inhconstants)\|[Methods](https://developer.android.com/reference/org/w3c/dom/Element#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/org/w3c/dom/Element#inhmethods)  

# Element

`
public


interface
Element
`  
`


implements

`[Node](https://developer.android.com/reference/org/w3c/dom/Node)`


`

|---------------------|
| org.w3c.dom.Element |

<br />

*** ** * ** ***

The`Element`interface represents an element in an HTML or XML document. Elements may have attributes associated with them; since the`Element`interface inherits from`Node`, the generic`Node`interface attribute`attributes`may be used to retrieve the set of all attributes for an element. There are methods on the`Element`interface to retrieve either an`Attr`object by name or an attribute value by name. In XML, where an attribute value may contain entity references, an`Attr`object should be retrieved to examine the possibly fairly complex sub-tree representing the attribute value. On the other hand, in HTML, where all attributes have simple string values, methods to directly access an attribute value can safely be used as a convenience.

**Note:** In DOM Level 2, the method`normalize`is inherited from the`Node`interface where it was moved.

See also the[Document Object Model (DOM) Level 3 Core Specification](http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407).

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ### Inherited constants                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From interface[org.w3c.dom.Node](https://developer.android.com/reference/org/w3c/dom/Node) |---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `short` | [ATTRIBUTE_NODE](https://developer.android.com/reference/org/w3c/dom/Node#ATTRIBUTE_NODE) The node is an`Attr`.                                                                                                             | | `short` | [CDATA_SECTION_NODE](https://developer.android.com/reference/org/w3c/dom/Node#CDATA_SECTION_NODE) The node is a`CDATASection`.                                                                                              | | `short` | [COMMENT_NODE](https://developer.android.com/reference/org/w3c/dom/Node#COMMENT_NODE) The node is a`Comment`.                                                                                                               | | `short` | [DOCUMENT_FRAGMENT_NODE](https://developer.android.com/reference/org/w3c/dom/Node#DOCUMENT_FRAGMENT_NODE) The node is a`DocumentFragment`.                                                                                  | | `short` | [DOCUMENT_NODE](https://developer.android.com/reference/org/w3c/dom/Node#DOCUMENT_NODE) The node is a`Document`.                                                                                                            | | `short` | [DOCUMENT_POSITION_CONTAINED_BY](https://developer.android.com/reference/org/w3c/dom/Node#DOCUMENT_POSITION_CONTAINED_BY) The node is contained by the reference node.                                                      | | `short` | [DOCUMENT_POSITION_CONTAINS](https://developer.android.com/reference/org/w3c/dom/Node#DOCUMENT_POSITION_CONTAINS) The node contains the reference node.                                                                     | | `short` | [DOCUMENT_POSITION_DISCONNECTED](https://developer.android.com/reference/org/w3c/dom/Node#DOCUMENT_POSITION_DISCONNECTED) The two nodes are disconnected.                                                                   | | `short` | [DOCUMENT_POSITION_FOLLOWING](https://developer.android.com/reference/org/w3c/dom/Node#DOCUMENT_POSITION_FOLLOWING) The node follows the reference node.                                                                    | | `short` | [DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC](https://developer.android.com/reference/org/w3c/dom/Node#DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC) The determination of preceding versus following is implementation-specific. | | `short` | [DOCUMENT_POSITION_PRECEDING](https://developer.android.com/reference/org/w3c/dom/Node#DOCUMENT_POSITION_PRECEDING) The second node precedes the reference node.                                                            | | `short` | [DOCUMENT_TYPE_NODE](https://developer.android.com/reference/org/w3c/dom/Node#DOCUMENT_TYPE_NODE) The node is a`DocumentType`.                                                                                              | | `short` | [ELEMENT_NODE](https://developer.android.com/reference/org/w3c/dom/Node#ELEMENT_NODE) The node is an`Element`.                                                                                                              | | `short` | [ENTITY_NODE](https://developer.android.com/reference/org/w3c/dom/Node#ENTITY_NODE) The node is an`Entity`.                                                                                                                 | | `short` | [ENTITY_REFERENCE_NODE](https://developer.android.com/reference/org/w3c/dom/Node#ENTITY_REFERENCE_NODE) The node is an`EntityReference`.                                                                                    | | `short` | [NOTATION_NODE](https://developer.android.com/reference/org/w3c/dom/Node#NOTATION_NODE) The node is a`Notation`.                                                                                                            | | `short` | [PROCESSING_INSTRUCTION_NODE](https://developer.android.com/reference/org/w3c/dom/Node#PROCESSING_INSTRUCTION_NODE) The node is a`ProcessingInstruction`.                                                                   | | `short` | [TEXT_NODE](https://developer.android.com/reference/org/w3c/dom/Node#TEXT_NODE) The node is a`Text`node.                                                                                                                    | |

|                                                                                                                                                                                                                                                                 ### Public methods                                                                                                                                                                                                                                                                 ||
|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract `[String](https://developer.android.com/reference/java/lang/String)       | ` `[getAttribute](https://developer.android.com/reference/org/w3c/dom/Element#getAttribute(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Retrieves an attribute value by name.                                                                                                                                                                                                                            |
| ` abstract `[String](https://developer.android.com/reference/java/lang/String)       | ` `[getAttributeNS](https://developer.android.com/reference/org/w3c/dom/Element#getAttributeNS(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` namespaceURI, `[String](https://developer.android.com/reference/java/lang/String)` localName) ` Retrieves an attribute value by local name and namespace URI.                                                                                    |
| ` abstract `[Attr](https://developer.android.com/reference/org/w3c/dom/Attr)         | ` `[getAttributeNode](https://developer.android.com/reference/org/w3c/dom/Element#getAttributeNode(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Retrieves an attribute node by name.                                                                                                                                                                                                                     |
| ` abstract `[Attr](https://developer.android.com/reference/org/w3c/dom/Attr)         | ` `[getAttributeNodeNS](https://developer.android.com/reference/org/w3c/dom/Element#getAttributeNodeNS(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` namespaceURI, `[String](https://developer.android.com/reference/java/lang/String)` localName) ` Retrieves an`Attr`node by local name and namespace URI.                                                                                  |
| ` abstract `[NodeList](https://developer.android.com/reference/org/w3c/dom/NodeList) | ` `[getElementsByTagName](https://developer.android.com/reference/org/w3c/dom/Element#getElementsByTagName(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Returns a`NodeList`of all descendant`Elements`with a given tag name, in document order.                                                                                                                                                          |
| ` abstract `[NodeList](https://developer.android.com/reference/org/w3c/dom/NodeList) | ` `[getElementsByTagNameNS](https://developer.android.com/reference/org/w3c/dom/Element#getElementsByTagNameNS(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` namespaceURI, `[String](https://developer.android.com/reference/java/lang/String)` localName) ` Returns a`NodeList`of all the descendant`Elements`with a given local name and namespace URI in document order.                   |
| ` abstract `[TypeInfo](https://developer.android.com/reference/org/w3c/dom/TypeInfo) | ` `[getSchemaTypeInfo](https://developer.android.com/reference/org/w3c/dom/Element#getSchemaTypeInfo())`() ` The type information associated with this element.                                                                                                                                                                                                                                                                                              |
| ` abstract `[String](https://developer.android.com/reference/java/lang/String)       | ` `[getTagName](https://developer.android.com/reference/org/w3c/dom/Element#getTagName())`() ` The name of the element.                                                                                                                                                                                                                                                                                                                                      |
| ` abstract boolean`                                                                  | ` `[hasAttribute](https://developer.android.com/reference/org/w3c/dom/Element#hasAttribute(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Returns`true`when an attribute with a given name is specified on this element or has a default value,`false`otherwise.                                                                                                                                           |
| ` abstract boolean`                                                                  | ` `[hasAttributeNS](https://developer.android.com/reference/org/w3c/dom/Element#hasAttributeNS(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` namespaceURI, `[String](https://developer.android.com/reference/java/lang/String)` localName) ` Returns`true`when an attribute with a given local name and namespace URI is specified on this element or has a default value,`false`otherwise.   |
| ` abstract void`                                                                     | ` `[removeAttribute](https://developer.android.com/reference/org/w3c/dom/Element#removeAttribute(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Removes an attribute by name.                                                                                                                                                                                                                              |
| ` abstract void`                                                                     | ` `[removeAttributeNS](https://developer.android.com/reference/org/w3c/dom/Element#removeAttributeNS(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` namespaceURI, `[String](https://developer.android.com/reference/java/lang/String)` localName) ` Removes an attribute by local name and namespace URI.                                                                                      |
| ` abstract `[Attr](https://developer.android.com/reference/org/w3c/dom/Attr)         | ` `[removeAttributeNode](https://developer.android.com/reference/org/w3c/dom/Element#removeAttributeNode(org.w3c.dom.Attr))`(`[Attr](https://developer.android.com/reference/org/w3c/dom/Attr)` oldAttr) ` Removes the specified attribute node.                                                                                                                                                                                                             |
| ` abstract void`                                                                     | ` `[setAttribute](https://developer.android.com/reference/org/w3c/dom/Element#setAttribute(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name, `[String](https://developer.android.com/reference/java/lang/String)` value) ` Adds a new attribute.                                                                                                                                            |
| ` abstract void`                                                                     | ` `[setAttributeNS](https://developer.android.com/reference/org/w3c/dom/Element#setAttributeNS(java.lang.String,%20java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` namespaceURI, `[String](https://developer.android.com/reference/java/lang/String)` qualifiedName, `[String](https://developer.android.com/reference/java/lang/String)` value) ` Adds a new attribute.                        |
| ` abstract `[Attr](https://developer.android.com/reference/org/w3c/dom/Attr)         | ` `[setAttributeNode](https://developer.android.com/reference/org/w3c/dom/Element#setAttributeNode(org.w3c.dom.Attr))`(`[Attr](https://developer.android.com/reference/org/w3c/dom/Attr)` newAttr) ` Adds a new attribute node.                                                                                                                                                                                                                              |
| ` abstract `[Attr](https://developer.android.com/reference/org/w3c/dom/Attr)         | ` `[setAttributeNodeNS](https://developer.android.com/reference/org/w3c/dom/Element#setAttributeNodeNS(org.w3c.dom.Attr))`(`[Attr](https://developer.android.com/reference/org/w3c/dom/Attr)` newAttr) ` Adds a new attribute.                                                                                                                                                                                                                               |
| ` abstract void`                                                                     | ` `[setIdAttribute](https://developer.android.com/reference/org/w3c/dom/Element#setIdAttribute(java.lang.String,%20boolean))`(`[String](https://developer.android.com/reference/java/lang/String)` name, boolean isId) ` If the parameter`isId`is`true`, this method declares the specified attribute to be a user-determined ID attribute .                                                                                                                 |
| ` abstract void`                                                                     | ` `[setIdAttributeNS](https://developer.android.com/reference/org/w3c/dom/Element#setIdAttributeNS(java.lang.String,%20java.lang.String,%20boolean))`(`[String](https://developer.android.com/reference/java/lang/String)` namespaceURI, `[String](https://developer.android.com/reference/java/lang/String)` localName, boolean isId) ` If the parameter`isId`is`true`, this method declares the specified attribute to be a user-determined ID attribute . |
| ` abstract void`                                                                     | ` `[setIdAttributeNode](https://developer.android.com/reference/org/w3c/dom/Element#setIdAttributeNode(org.w3c.dom.Attr,%20boolean))`(`[Attr](https://developer.android.com/reference/org/w3c/dom/Attr)` idAttr, boolean isId) ` If the parameter`isId`is`true`, this method declares the specified attribute to be a user-determined ID attribute .                                                                                                         |

| ### Inherited methods |
|-----------------------|---|
| From interface` `[org.w3c.dom.Node](https://developer.android.com/reference/org/w3c/dom/Node)` ` |----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[Node](https://developer.android.com/reference/org/w3c/dom/Node)                 | ` `[appendChild](https://developer.android.com/reference/org/w3c/dom/Node#appendChild(org.w3c.dom.Node))`(`[Node](https://developer.android.com/reference/org/w3c/dom/Node)` newChild) ` Adds the node`newChild`to the end of the list of children of this node.                                                                                                                                                                                                 | | ` abstract `[Node](https://developer.android.com/reference/org/w3c/dom/Node)                 | ` `[cloneNode](https://developer.android.com/reference/org/w3c/dom/Node#cloneNode(boolean))`(boolean deep) ` Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.                                                                                                                                                                                                                                                             | | ` abstract short`                                                                            | ` `[compareDocumentPosition](https://developer.android.com/reference/org/w3c/dom/Node#compareDocumentPosition(org.w3c.dom.Node))`(`[Node](https://developer.android.com/reference/org/w3c/dom/Node)` other) ` Compares the reference node, i.e.                                                                                                                                                                                                                  | | ` abstract `[NamedNodeMap](https://developer.android.com/reference/org/w3c/dom/NamedNodeMap) | ` `[getAttributes](https://developer.android.com/reference/org/w3c/dom/Node#getAttributes())`() ` A`NamedNodeMap`containing the attributes of this node (if it is an`Element`) or`null`otherwise.                                                                                                                                                                                                                                                                | | ` abstract `[String](https://developer.android.com/reference/java/lang/String)               | ` `[getBaseURI](https://developer.android.com/reference/org/w3c/dom/Node#getBaseURI())`() ` The absolute base URI of this node or`null`if the implementation wasn't able to obtain an absolute URI.                                                                                                                                                                                                                                                              | | ` abstract `[NodeList](https://developer.android.com/reference/org/w3c/dom/NodeList)         | ` `[getChildNodes](https://developer.android.com/reference/org/w3c/dom/Node#getChildNodes())`() ` A`NodeList`that contains all children of this node.                                                                                                                                                                                                                                                                                                            | | ` abstract `[Object](https://developer.android.com/reference/java/lang/Object)               | ` `[getFeature](https://developer.android.com/reference/org/w3c/dom/Node#getFeature(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` feature, `[String](https://developer.android.com/reference/java/lang/String)` version) ` This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in .                                 | | ` abstract `[Node](https://developer.android.com/reference/org/w3c/dom/Node)                 | ` `[getFirstChild](https://developer.android.com/reference/org/w3c/dom/Node#getFirstChild())`() ` The first child of this node.                                                                                                                                                                                                                                                                                                                                  | | ` abstract `[Node](https://developer.android.com/reference/org/w3c/dom/Node)                 | ` `[getLastChild](https://developer.android.com/reference/org/w3c/dom/Node#getLastChild())`() ` The last child of this node.                                                                                                                                                                                                                                                                                                                                     | | ` abstract `[String](https://developer.android.com/reference/java/lang/String)               | ` `[getLocalName](https://developer.android.com/reference/org/w3c/dom/Node#getLocalName())`() ` Returns the local part of the qualified name of this node.                                                                                                                                                                                                                                                                                                       | | ` abstract `[String](https://developer.android.com/reference/java/lang/String)               | ` `[getNamespaceURI](https://developer.android.com/reference/org/w3c/dom/Node#getNamespaceURI())`() ` The namespace URI of this node, or`null`if it is unspecified (see ).                                                                                                                                                                                                                                                                                       | | ` abstract `[Node](https://developer.android.com/reference/org/w3c/dom/Node)                 | ` `[getNextSibling](https://developer.android.com/reference/org/w3c/dom/Node#getNextSibling())`() ` The node immediately following this node.                                                                                                                                                                                                                                                                                                                    | | ` abstract `[String](https://developer.android.com/reference/java/lang/String)               | ` `[getNodeName](https://developer.android.com/reference/org/w3c/dom/Node#getNodeName())`() ` The name of this node, depending on its type; see the table above.                                                                                                                                                                                                                                                                                                 | | ` abstract short`                                                                            | ` `[getNodeType](https://developer.android.com/reference/org/w3c/dom/Node#getNodeType())`() ` A code representing the type of the underlying object, as defined above.                                                                                                                                                                                                                                                                                           | | ` abstract `[String](https://developer.android.com/reference/java/lang/String)               | ` `[getNodeValue](https://developer.android.com/reference/org/w3c/dom/Node#getNodeValue())`() ` The value of this node, depending on its type; see the table above.                                                                                                                                                                                                                                                                                              | | ` abstract `[Document](https://developer.android.com/reference/org/w3c/dom/Document)         | ` `[getOwnerDocument](https://developer.android.com/reference/org/w3c/dom/Node#getOwnerDocument())`() ` The`Document`object associated with this node.                                                                                                                                                                                                                                                                                                           | | ` abstract `[Node](https://developer.android.com/reference/org/w3c/dom/Node)                 | ` `[getParentNode](https://developer.android.com/reference/org/w3c/dom/Node#getParentNode())`() ` The parent of this node.                                                                                                                                                                                                                                                                                                                                       | | ` abstract `[String](https://developer.android.com/reference/java/lang/String)               | ` `[getPrefix](https://developer.android.com/reference/org/w3c/dom/Node#getPrefix())`() ` The namespace prefix of this node, or`null`if it is unspecified.                                                                                                                                                                                                                                                                                                       | | ` abstract `[Node](https://developer.android.com/reference/org/w3c/dom/Node)                 | ` `[getPreviousSibling](https://developer.android.com/reference/org/w3c/dom/Node#getPreviousSibling())`() ` The node immediately preceding this node.                                                                                                                                                                                                                                                                                                            | | ` abstract `[String](https://developer.android.com/reference/java/lang/String)               | ` `[getTextContent](https://developer.android.com/reference/org/w3c/dom/Node#getTextContent())`() ` This attribute returns the text content of this node and its descendants.                                                                                                                                                                                                                                                                                    | | ` abstract `[Object](https://developer.android.com/reference/java/lang/Object)               | ` `[getUserData](https://developer.android.com/reference/org/w3c/dom/Node#getUserData(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` key) ` Retrieves the object associated to a key on a this node.                                                                                                                                                                                                                   | | ` abstract boolean`                                                                          | ` `[hasAttributes](https://developer.android.com/reference/org/w3c/dom/Node#hasAttributes())`() ` Returns whether this node (if it is an element) has any attributes.                                                                                                                                                                                                                                                                                            | | ` abstract boolean`                                                                          | ` `[hasChildNodes](https://developer.android.com/reference/org/w3c/dom/Node#hasChildNodes())`() ` Returns whether this node has any children.                                                                                                                                                                                                                                                                                                                    | | ` abstract `[Node](https://developer.android.com/reference/org/w3c/dom/Node)                 | ` `[insertBefore](https://developer.android.com/reference/org/w3c/dom/Node#insertBefore(org.w3c.dom.Node,%20org.w3c.dom.Node))`(`[Node](https://developer.android.com/reference/org/w3c/dom/Node)` newChild, `[Node](https://developer.android.com/reference/org/w3c/dom/Node)` refChild) ` Inserts the node`newChild`before the existing child node`refChild`.                                                                                                  | | ` abstract boolean`                                                                          | ` `[isDefaultNamespace](https://developer.android.com/reference/org/w3c/dom/Node#isDefaultNamespace(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` namespaceURI) ` This method checks if the specified`namespaceURI`is the default namespace or not.                                                                                                                                                                   | | ` abstract boolean`                                                                          | ` `[isEqualNode](https://developer.android.com/reference/org/w3c/dom/Node#isEqualNode(org.w3c.dom.Node))`(`[Node](https://developer.android.com/reference/org/w3c/dom/Node)` arg) ` Tests whether two nodes are equal.                                                                                                                                                                                                                                           | | ` abstract boolean`                                                                          | ` `[isSameNode](https://developer.android.com/reference/org/w3c/dom/Node#isSameNode(org.w3c.dom.Node))`(`[Node](https://developer.android.com/reference/org/w3c/dom/Node)` other) ` Returns whether this node is the same node as the given one.                                                                                                                                                                                                                 | | ` abstract boolean`                                                                          | ` `[isSupported](https://developer.android.com/reference/org/w3c/dom/Node#isSupported(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` feature, `[String](https://developer.android.com/reference/java/lang/String)` version) ` Tests whether the DOM implementation implements a specific feature and that feature is supported by this node, as specified in .                                     | | ` abstract `[String](https://developer.android.com/reference/java/lang/String)               | ` `[lookupNamespaceURI](https://developer.android.com/reference/org/w3c/dom/Node#lookupNamespaceURI(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` prefix) ` Look up the namespace URI associated to the given prefix, starting from this node.                                                                                                                                                                        | | ` abstract `[String](https://developer.android.com/reference/java/lang/String)               | ` `[lookupPrefix](https://developer.android.com/reference/org/w3c/dom/Node#lookupPrefix(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` namespaceURI) ` Look up the prefix associated to the given namespace URI, starting from this node.                                                                                                                                                                              | | ` abstract void`                                                                             | ` `[normalize](https://developer.android.com/reference/org/w3c/dom/Node#normalize())`() ` Puts all`Text`nodes in the full depth of the sub-tree underneath this`Node`, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates`Text`nodes, i.e., there are neither adjacent`Text`nodes nor empty`Text`nodes.                                   | | ` abstract `[Node](https://developer.android.com/reference/org/w3c/dom/Node)                 | ` `[removeChild](https://developer.android.com/reference/org/w3c/dom/Node#removeChild(org.w3c.dom.Node))`(`[Node](https://developer.android.com/reference/org/w3c/dom/Node)` oldChild) ` Removes the child node indicated by`oldChild`from the list of children, and returns it.                                                                                                                                                                                 | | ` abstract `[Node](https://developer.android.com/reference/org/w3c/dom/Node)                 | ` `[replaceChild](https://developer.android.com/reference/org/w3c/dom/Node#replaceChild(org.w3c.dom.Node,%20org.w3c.dom.Node))`(`[Node](https://developer.android.com/reference/org/w3c/dom/Node)` newChild, `[Node](https://developer.android.com/reference/org/w3c/dom/Node)` oldChild) ` Replaces the child node`oldChild`with`newChild`in the list of children, and returns the`oldChild`node.                                                               | | ` abstract void`                                                                             | ` `[setNodeValue](https://developer.android.com/reference/org/w3c/dom/Node#setNodeValue(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` nodeValue) ` The value of this node, depending on its type; see the table above.                                                                                                                                                                                                | | ` abstract void`                                                                             | ` `[setPrefix](https://developer.android.com/reference/org/w3c/dom/Node#setPrefix(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` prefix) ` The namespace prefix of this node, or`null`if it is unspecified.                                                                                                                                                                                                            | | ` abstract void`                                                                             | ` `[setTextContent](https://developer.android.com/reference/org/w3c/dom/Node#setTextContent(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` textContent) ` This attribute returns the text content of this node and its descendants.                                                                                                                                                                                    | | ` abstract `[Object](https://developer.android.com/reference/java/lang/Object)               | ` `[setUserData](https://developer.android.com/reference/org/w3c/dom/Node#setUserData(java.lang.String,%20java.lang.Object,%20org.w3c.dom.UserDataHandler))`(`[String](https://developer.android.com/reference/java/lang/String)` key, `[Object](https://developer.android.com/reference/java/lang/Object)` data, `[UserDataHandler](https://developer.android.com/reference/org/w3c/dom/UserDataHandler)` handler) ` Associate an object to a key on this node. | ||

## Public methods

### getAttribute

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract String getAttribute (String name)
```

Retrieves an attribute value by name.

<br />

|                           Parameters                            ||
|--------|---------------------------------------------------------|
| `name` | `String`: The name of the attribute to retrieve. <br /> |

|                                                                                         Returns                                                                                          ||
|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | The`Attr`value as a string, or the empty string if that attribute does not have a specified or default value. <br /> |

### getAttributeNS

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract String getAttributeNS (String namespaceURI, 
                String localName)
```

Retrieves an attribute value by local name and namespace URI.  
Per \[[XML Namespaces](http://www.w3.org/TR/1999/REC-xml-names-19990114/)\] , applications must use the value`null`as the`namespaceURI`parameter for methods if they wish to have no namespace.

<br />

|                                    Parameters                                    ||
|----------------|------------------------------------------------------------------|
| `namespaceURI` | `String`: The namespace URI of the attribute to retrieve. <br /> |
| `localName`    | `String`: The local name of the attribute to retrieve. <br />    |

|                                                                                         Returns                                                                                          ||
|--------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | The`Attr`value as a string, or the empty string if that attribute does not have a specified or default value. <br /> |

|                                                                                                                                                                Throws                                                                                                                                                                 ||
|----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DOMException](https://developer.android.com/reference/org/w3c/dom/DOMException) | NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature`"XML"`and the language exposed through the Document does not support XML Namespaces (such as \[[HTML 4.01](http://www.w3.org/TR/1999/REC-html401-19991224/)\]). |

### getAttributeNode

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Attr getAttributeNode (String name)
```

Retrieves an attribute node by name.  
To retrieve an attribute node by qualified name and namespace URI, use the`getAttributeNodeNS`method.

<br />

|                                  Parameters                                  ||
|--------|----------------------------------------------------------------------|
| `name` | `String`: The name (`nodeName`) of the attribute to retrieve. <br /> |

|                                                                              Returns                                                                               ||
|------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|
| [Attr](https://developer.android.com/reference/org/w3c/dom/Attr) | The`Attr`node with the specified name (`nodeName`) or`null`if there is no such attribute. <br /> |

### getAttributeNodeNS

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Attr getAttributeNodeNS (String namespaceURI, 
                String localName)
```

Retrieves an`Attr`node by local name and namespace URI.  
Per \[[XML Namespaces](http://www.w3.org/TR/1999/REC-xml-names-19990114/)\] , applications must use the value`null`as the`namespaceURI`parameter for methods if they wish to have no namespace.

<br />

|                                    Parameters                                    ||
|----------------|------------------------------------------------------------------|
| `namespaceURI` | `String`: The namespace URI of the attribute to retrieve. <br /> |
| `localName`    | `String`: The local name of the attribute to retrieve. <br />    |

|                                                                                         Returns                                                                                         ||
|------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| [Attr](https://developer.android.com/reference/org/w3c/dom/Attr) | The`Attr`node with the specified attribute local name and namespace URI or`null`if there is no such attribute. <br /> |

|                                                                                                                                                                Throws                                                                                                                                                                 ||
|----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DOMException](https://developer.android.com/reference/org/w3c/dom/DOMException) | NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature`"XML"`and the language exposed through the Document does not support XML Namespaces (such as \[[HTML 4.01](http://www.w3.org/TR/1999/REC-html401-19991224/)\]). |

### getElementsByTagName

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract NodeList getElementsByTagName (String name)
```

Returns a`NodeList`of all descendant`Elements`with a given tag name, in document order.

<br />

|                                             Parameters                                             ||
|--------|--------------------------------------------------------------------------------------------|
| `name` | `String`: The name of the tag to match on. The special value "\*" matches all tags. <br /> |

|                                                      Returns                                                       ||
|--------------------------------------------------------------------------|------------------------------------------|
| [NodeList](https://developer.android.com/reference/org/w3c/dom/NodeList) | A list of matching`Element`nodes. <br /> |

### getElementsByTagNameNS

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract NodeList getElementsByTagNameNS (String namespaceURI, 
                String localName)
```

Returns a`NodeList`of all the descendant`Elements`with a given local name and namespace URI in document order.

<br />

|                                                           Parameters                                                           ||
|----------------|----------------------------------------------------------------------------------------------------------------|
| `namespaceURI` | `String`: The namespace URI of the elements to match on. The special value "\*" matches all namespaces. <br /> |
| `localName`    | `String`: The local name of the elements to match on. The special value "\*" matches all local names. <br />   |

|                                                                   Returns                                                                    ||
|--------------------------------------------------------------------------|--------------------------------------------------------------------|
| [NodeList](https://developer.android.com/reference/org/w3c/dom/NodeList) | A new`NodeList`object containing all the matched`Elements`. <br /> |

|                                                                                                                                                                Throws                                                                                                                                                                 ||
|----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DOMException](https://developer.android.com/reference/org/w3c/dom/DOMException) | NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature`"XML"`and the language exposed through the Document does not support XML Namespaces (such as \[[HTML 4.01](http://www.w3.org/TR/1999/REC-html401-19991224/)\]). |

### getSchemaTypeInfo

Added in[API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract TypeInfo getSchemaTypeInfo ()
```

The type information associated with this element.

<br />

|                                     Returns                                      ||
|--------------------------------------------------------------------------|--------|
| [TypeInfo](https://developer.android.com/reference/org/w3c/dom/TypeInfo) | <br /> |

### getTagName

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract String getTagName ()
```

The name of the element. If`Node.localName`is different from`null`, this attribute is a qualified name. For example, in:  

```
 <elementExample id="demo"> ...
 </elementExample> , 
```
`tagName`has the value`"elementExample"`. Note that this is case-preserving in XML, as are all of the operations of the DOM. The HTML DOM returns the`tagName`of an HTML element in the canonical uppercase form, regardless of the case in the source HTML document.

<br />

<br />

|                                  Returns                                   ||
|--------------------------------------------------------------------|--------|
| [String](https://developer.android.com/reference/java/lang/String) | <br /> |

### hasAttribute

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean hasAttribute (String name)
```

Returns`true`when an attribute with a given name is specified on this element or has a default value,`false`otherwise.

<br />

|                           Parameters                            ||
|--------|---------------------------------------------------------|
| `name` | `String`: The name of the attribute to look for. <br /> |

|                                                              Returns                                                              ||
|-----------|------------------------------------------------------------------------------------------------------------------------|
| `boolean` | `true`if an attribute with the given name is specified on this element or has a default value,`false`otherwise. <br /> |

### hasAttributeNS

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract boolean hasAttributeNS (String namespaceURI, 
                String localName)
```

Returns`true`when an attribute with a given local name and namespace URI is specified on this element or has a default value,`false`otherwise.  
Per \[[XML Namespaces](http://www.w3.org/TR/1999/REC-xml-names-19990114/)\] , applications must use the value`null`as the`namespaceURI`parameter for methods if they wish to have no namespace.

<br />

|                                    Parameters                                    ||
|----------------|------------------------------------------------------------------|
| `namespaceURI` | `String`: The namespace URI of the attribute to look for. <br /> |
| `localName`    | `String`: The local name of the attribute to look for. <br />    |

|                                                                          Returns                                                                          ||
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | `true`if an attribute with the given local name and namespace URI is specified or has a default value on this element,`false`otherwise. <br /> |

|                                                                                                                                                                Throws                                                                                                                                                                 ||
|----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DOMException](https://developer.android.com/reference/org/w3c/dom/DOMException) | NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature`"XML"`and the language exposed through the Document does not support XML Namespaces (such as \[[HTML 4.01](http://www.w3.org/TR/1999/REC-html401-19991224/)\]). |

### removeAttribute

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void removeAttribute (String name)
```

Removes an attribute by name. If a default value for the removed attribute is defined in the DTD, a new attribute immediately appears with the default value as well as the corresponding namespace URI, local name, and prefix when applicable. The implementation may handle default values from other schemas similarly but applications should use`Document.normalizeDocument()`to guarantee this information is up-to-date.  
If no attribute with this name is found, this method has no effect.  
To remove an attribute by local name and namespace URI, use the`removeAttributeNS`method.

<br />

|                          Parameters                           ||
|--------|-------------------------------------------------------|
| `name` | `String`: The name of the attribute to remove. <br /> |

|                                                                     Throws                                                                      ||
|----------------------------------------------------------------------------------|---------------------------------------------------------------|
| [DOMException](https://developer.android.com/reference/org/w3c/dom/DOMException) | NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |

### removeAttributeNS

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void removeAttributeNS (String namespaceURI, 
                String localName)
```

Removes an attribute by local name and namespace URI. If a default value for the removed attribute is defined in the DTD, a new attribute immediately appears with the default value as well as the corresponding namespace URI, local name, and prefix when applicable. The implementation may handle default values from other schemas similarly but applications should use`Document.normalizeDocument()`to guarantee this information is up-to-date.  
If no attribute with this local name and namespace URI is found, this method has no effect.  
Per \[[XML Namespaces](http://www.w3.org/TR/1999/REC-xml-names-19990114/)\] , applications must use the value`null`as the`namespaceURI`parameter for methods if they wish to have no namespace.

<br />

|                                   Parameters                                   ||
|----------------|----------------------------------------------------------------|
| `namespaceURI` | `String`: The namespace URI of the attribute to remove. <br /> |
| `localName`    | `String`: The local name of the attribute to remove. <br />    |

|                                                                                                                                                                                               Throws                                                                                                                                                                                                ||
|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DOMException](https://developer.android.com/reference/org/w3c/dom/DOMException) | NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature`"XML"`and the language exposed through the Document does not support XML Namespaces (such as \[[HTML 4.01](http://www.w3.org/TR/1999/REC-html401-19991224/)\]). |

### removeAttributeNode

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Attr removeAttributeNode (Attr oldAttr)
```

Removes the specified attribute node. If a default value for the removed`Attr`node is defined in the DTD, a new node immediately appears with the default value as well as the corresponding namespace URI, local name, and prefix when applicable. The implementation may handle default values from other schemas similarly but applications should use`Document.normalizeDocument()`to guarantee this information is up-to-date.

<br />

|                                 Parameters                                 ||
|-----------|-----------------------------------------------------------------|
| `oldAttr` | `Attr`: The`Attr`node to remove from the attribute list. <br /> |

|                                                 Returns                                                  ||
|------------------------------------------------------------------|----------------------------------------|
| [Attr](https://developer.android.com/reference/org/w3c/dom/Attr) | The`Attr`node that was removed. <br /> |

|                                                                                                        Throws                                                                                                        ||
|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|
| [DOMException](https://developer.android.com/reference/org/w3c/dom/DOMException) | NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. NOT_FOUND_ERR: Raised if`oldAttr`is not an attribute of the element. |

### setAttribute

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void setAttribute (String name, 
                String value)
```

Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an`Attr`node plus any`Text`and`EntityReference`nodes, build the appropriate subtree, and use`setAttributeNode`to assign it as the value of an attribute.  
To set an attribute with a qualified name and namespace URI, use the`setAttributeNS`method.

<br />

|                               Parameters                                ||
|---------|----------------------------------------------------------------|
| `name`  | `String`: The name of the attribute to create or alter. <br /> |
| `value` | `String`: Value to set in string form. <br />                  |

|                                                                                                                                                   Throws                                                                                                                                                   ||
|----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DOMException](https://developer.android.com/reference/org/w3c/dom/DOMException) | INVALID_CHARACTER_ERR: Raised if the specified name is not an XML name according to the XML version in use specified in the`Document.xmlVersion`attribute. NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |

### setAttributeNS

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void setAttributeNS (String namespaceURI, 
                String qualifiedName, 
                String value)
```

Adds a new attribute. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the`qualifiedName`, and its value is changed to be the`value`parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an`Attr`node plus any`Text`and`EntityReference`nodes, build the appropriate subtree, and use`setAttributeNodeNS`or`setAttributeNode`to assign it as the value of an attribute.  
Per \[[XML Namespaces](http://www.w3.org/TR/1999/REC-xml-names-19990114/)\] , applications must use the value`null`as the`namespaceURI`parameter for methods if they wish to have no namespace.

<br />

|                                        Parameters                                         ||
|-----------------|--------------------------------------------------------------------------|
| `namespaceURI`  | `String`: The namespace URI of the attribute to create or alter. <br />  |
| `qualifiedName` | `String`: The qualified name of the attribute to create or alter. <br /> |
| `value`         | `String`: The value to set in string form. <br />                        |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Throws                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ||
|----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DOMException](https://developer.android.com/reference/org/w3c/dom/DOMException) | INVALID_CHARACTER_ERR: Raised if the specified qualified name is not an XML name according to the XML version in use specified in the`Document.xmlVersion`attribute. NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. NAMESPACE_ERR: Raised if the`qualifiedName`is malformed per the Namespaces in XML specification, if the`qualifiedName`has a prefix and the`namespaceURI`is`null`, if the`qualifiedName`has a prefix that is "xml" and the`namespaceURI`is different from "<http://www.w3.org/XML/1998/namespace>", if the`qualifiedName`or its prefix is "xmlns" and the`namespaceURI`is different from "<http://www.w3.org/2000/xmlns/>", or if the`namespaceURI`is "<http://www.w3.org/2000/xmlns/>" and neither the`qualifiedName`nor its prefix is "xmlns". NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature`"XML"`and the language exposed through the Document does not support XML Namespaces (such as \[[HTML 4.01](http://www.w3.org/TR/1999/REC-html401-19991224/)\]). |

### setAttributeNode

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Attr setAttributeNode (Attr newAttr)
```

Adds a new attribute node. If an attribute with that name (`nodeName`) is already present in the element, it is replaced by the new one. Replacing an attribute node by itself has no effect.  
To add a new attribute node with a qualified name and namespace URI, use the`setAttributeNodeNS`method.

<br />

|                              Parameters                               ||
|-----------|------------------------------------------------------------|
| `newAttr` | `Attr`: The`Attr`node to add to the attribute list. <br /> |

|                                                                                              Returns                                                                                              ||
|------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|
| [Attr](https://developer.android.com/reference/org/w3c/dom/Attr) | If the`newAttr`attribute replaces an existing attribute, the replaced`Attr`node is returned, otherwise`null`is returned. <br /> |

|                                                                                                                                                                                                                    Throws                                                                                                                                                                                                                    ||
|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DOMException](https://developer.android.com/reference/org/w3c/dom/DOMException) | WRONG_DOCUMENT_ERR: Raised if`newAttr`was created from a different document than the one that created the element. NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. INUSE_ATTRIBUTE_ERR: Raised if`newAttr`is already an attribute of another`Element`object. The DOM user must explicitly clone`Attr`nodes to re-use them in other elements. |

### setAttributeNodeNS

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract Attr setAttributeNodeNS (Attr newAttr)
```

Adds a new attribute. If an attribute with that local name and that namespace URI is already present in the element, it is replaced by the new one. Replacing an attribute node by itself has no effect.  
Per \[[XML Namespaces](http://www.w3.org/TR/1999/REC-xml-names-19990114/)\] , applications must use the value`null`as the`namespaceURI`parameter for methods if they wish to have no namespace.

<br />

|                              Parameters                               ||
|-----------|------------------------------------------------------------|
| `newAttr` | `Attr`: The`Attr`node to add to the attribute list. <br /> |

|                                                                                                                   Returns                                                                                                                    ||
|------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Attr](https://developer.android.com/reference/org/w3c/dom/Attr) | If the`newAttr`attribute replaces an existing attribute with the same local name and namespace URI, the replaced`Attr`node is returned, otherwise`null`is returned. <br /> |

|                                                                                                                                                                                                                                                                                                                                              Throws                                                                                                                                                                                                                                                                                                                                              ||
|----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DOMException](https://developer.android.com/reference/org/w3c/dom/DOMException) | WRONG_DOCUMENT_ERR: Raised if`newAttr`was created from a different document than the one that created the element. NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. INUSE_ATTRIBUTE_ERR: Raised if`newAttr`is already an attribute of another`Element`object. The DOM user must explicitly clone`Attr`nodes to re-use them in other elements. NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature`"XML"`and the language exposed through the Document does not support XML Namespaces (such as \[[HTML 4.01](http://www.w3.org/TR/1999/REC-html401-19991224/)\]). |

### setIdAttribute

Added in[API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void setIdAttribute (String name, 
                boolean isId)
```

If the parameter`isId`is`true`, this method declares the specified attribute to be a user-determined ID attribute . This affects the value of`Attr.isId`and the behavior of`Document.getElementById`, but does not change any schema that may be in use, in particular this does not affect the`Attr.schemaTypeInfo`of the specified`Attr`node. Use the value`false`for the parameter`isId`to undeclare an attribute for being a user-determined ID attribute.  
To specify an attribute by local name and namespace URI, use the`setIdAttributeNS`method.

<br />

|                            Parameters                            ||
|--------|----------------------------------------------------------|
| `name` | `String`: The name of the attribute. <br />              |
| `isId` | `boolean`: Whether the attribute is a of type ID. <br /> |

|                                                                                                              Throws                                                                                                              ||
|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
| [DOMException](https://developer.android.com/reference/org/w3c/dom/DOMException) | NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. NOT_FOUND_ERR: Raised if the specified node is not an attribute of this element. |

### setIdAttributeNS

Added in[API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void setIdAttributeNS (String namespaceURI, 
                String localName, 
                boolean isId)
```

If the parameter`isId`is`true`, this method declares the specified attribute to be a user-determined ID attribute . This affects the value of`Attr.isId`and the behavior of`Document.getElementById`, but does not change any schema that may be in use, in particular this does not affect the`Attr.schemaTypeInfo`of the specified`Attr`node. Use the value`false`for the parameter`isId`to undeclare an attribute for being a user-determined ID attribute.

<br />

|                                Parameters                                ||
|----------------|----------------------------------------------------------|
| `namespaceURI` | `String`: The namespace URI of the attribute. <br />     |
| `localName`    | `String`: The local name of the attribute. <br />        |
| `isId`         | `boolean`: Whether the attribute is a of type ID. <br /> |

|                                                                                                              Throws                                                                                                              ||
|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
| [DOMException](https://developer.android.com/reference/org/w3c/dom/DOMException) | NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. NOT_FOUND_ERR: Raised if the specified node is not an attribute of this element. |

### setIdAttributeNode

Added in[API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public abstract void setIdAttributeNode (Attr idAttr, 
                boolean isId)
```

If the parameter`isId`is`true`, this method declares the specified attribute to be a user-determined ID attribute . This affects the value of`Attr.isId`and the behavior of`Document.getElementById`, but does not change any schema that may be in use, in particular this does not affect the`Attr.schemaTypeInfo`of the specified`Attr`node. Use the value`false`for the parameter`isId`to undeclare an attribute for being a user-determined ID attribute.

<br />

|                             Parameters                             ||
|----------|----------------------------------------------------------|
| `idAttr` | `Attr`: The attribute node. <br />                       |
| `isId`   | `boolean`: Whether the attribute is a of type ID. <br /> |

|                                                                                                              Throws                                                                                                              ||
|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
| [DOMException](https://developer.android.com/reference/org/w3c/dom/DOMException) | NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. NOT_FOUND_ERR: Raised if the specified node is not an attribute of this element. |