<h1>xercesc::DOMElement Class Reference</h1><!-- doxytag: class="xercesc::DOMElement" --><!-- doxytag: inherits="xercesc::DOMNode" -->By far the vast majority of objects (apart from text) that authors encounter when traversing a document are <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code> nodes.
Inheritance diagram for xercesc::DOMElement:<p><center><imgsrc="classxercesc_1_1DOMElement__inherit__graph.png"border="0"usemap="#xercesc_1_1DOMElement__inherit__map"alt="Inheritance graph"></center>
<center><fontsize="2">[<ahref="graph_legend.html">legend</a>]</font></center><ahref="classxercesc_1_1DOMElement-members.html">List of all members.</a><tableborder="0"cellpadding="0"cellspacing="0">
<tr><td></td></tr>
<tr><tdcolspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><tdcolspan="2"><divclass="groupHeader">Functions introduced in DOM Level 1</div></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Retrieves an attribute value by name. <ahref="#bbf9718a26c7e97916ccd1027f7b1987"></a><br></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Retrieves an <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> node by name. <ahref="#c917d8db889c28f9b3e6055d33b72364"></a><br></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns a <code><aclass="el"href="classxercesc_1_1DOMNodeList.html">DOMNodeList</a></code> of all descendant elements with a given tag name, in the order in which they would be encountered in a preorder traversal of the <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code> tree. <ahref="#6a73e686210855713349e947d97a6c6d"></a><br></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Retrieves an attribute value by local name and namespace URI. <ahref="#bf209e7d1957d06bdca29a182ab97c50"></a><br></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Removes an attribute by local name and namespace URI. <ahref="#605bbd57ad1606ba624bad6c9b1e308a"></a><br></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Retrieves an <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> node by local name and namespace URI. <ahref="#736466756014aaa740ff9e7666d1d2b6"></a><br></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns a <code><aclass="el"href="classxercesc_1_1DOMNodeList.html">DOMNodeList</a></code> of all the <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code>s with a given local name and namespace URI in the order in which they would be encountered in a preorder traversal of the <code><aclass="el"href="classxercesc_1_1DOMDocument.html">DOMDocument</a></code> tree, starting from this node. <ahref="#6cad662791bb4e794c3ff3e81118b9c2"></a><br></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns <code>true</code> when an attribute with a given name is specified on this element or has a default value, <code>false</code> otherwise. <ahref="#6c8edc1a65e649c29d0d24c4a2f10794"></a><br></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns <code>true</code> when an attribute with a given local name and namespace URI is specified on this element or has a default value, <code>false</code> otherwise. <ahref="#6deba5788a156beaf28e76d9358aa38f"></a><br></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Declares the <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> specified by name to be of type ID. <ahref="#d0ef6a0d2d3f612ccdd4e6a62bd66eab"></a><br></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Declares the <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> specified by local name and namespace URI to be of type ID. <ahref="#92f7642742ff10dde42cf3c08f78f59d"></a><br></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Declares the <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> specified by node to be of type ID. <ahref="#2bc4166e386e8abe950cb2b080988e37"></a><br></td></tr>
<tr><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the type information associated with this element. <ahref="#e919bdf3eab20ed9e18e9a57f8aefdbf"></a><br></td></tr>
By far the vast majority of objects (apart from text) that authors encounter when traversing a document are <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code> nodes.
<p>
Assume the following XML document:<elementExample id="demo"><subelement1/><subelement2><subsubelement/></subelement2></elementExample><p>
When represented using DOM, the top node is an <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code> node for "elementExample", which contains two child <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code> nodes, one for "subelement1" and one for "subelement2". "subelement1" contains no child nodes. <p>
Elements may have attributes associated with them; since the <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code> interface inherits from <code><aclass="el"href="classxercesc_1_1DOMNode.html">DOMNode</a></code>, the generic <code><aclass="el"href="classxercesc_1_1DOMNode.html">DOMNode</a></code> interface method <code>getAttributes</code> may be used to retrieve the set of all attributes for an element. There are methods on the <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code> interface to retrieve either an <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> object by name or an attribute value by name. In XML, where an attribute value may contain entity references, an <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> 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.<p>
For example, in: <elementExample id="demo"> ... </elementExample> , <code>tagName</code> has the value <code>"elementExample"</code>. Note that this is case-preserving in XML, as are all of the operations of the DOM. <dlclass="since"compact><dt><b>Since:</b></dt><dd>DOM Level 1 </dd></dl>
<dlclass="return"compact><dt><b>Returns:</b></dt><dd>The <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> value as a string, or the empty string if that attribute does not have a specified or default value. </dd></dl>
<dlclass="return"compact><dt><b>Returns:</b></dt><dd>The <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> node with the specified name (<code>nodeName</code>) or <code>null</code> if there is no such attribute. </dd></dl>
Returns a <code><aclass="el"href="classxercesc_1_1DOMNodeList.html">DOMNodeList</a></code> of all descendant elements with a given tag name, in the order in which they would be encountered in a preorder traversal of the <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code> tree.
<p>
<dlcompact><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>name</em> </td><td>The name of the tag to match on. The special value "*" matches all tags. </td></tr>
<dlclass="return"compact><dt><b>Returns:</b></dt><dd>A list of matching <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code> nodes. </dd></dl>
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 <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> node plus any <code><aclass="el"href="classxercesc_1_1DOMText.html">DOMText</a></code> and <code><aclass="el"href="classxercesc_1_1DOMEntityReference.html">DOMEntityReference</a></code> nodes, build the appropriate subtree, and use <code>setAttributeNode</code> to assign it as the value of an attribute. <dlcompact><dt><b>Parameters:</b></dt><dd>
<tr><tdvalign="top"></td><tdvalign="top"><em><aclass="el"href="classxercesc_1_1DOMException.html">DOMException</a></em> </td><td>INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. <br>
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. </td></tr>
If an attribute with that name (<code>nodeName</code>) is already present in the element, it is replaced by the new one. <dlcompact><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>newAttr</em> </td><td>The <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> node to add to the attribute list. </td></tr>
</table>
</dl>
<dlclass="return"compact><dt><b>Returns:</b></dt><dd>If the <code>newAttr</code> attribute replaces an existing attribute, the replaced <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> node is returned, otherwise <code>null</code> is returned. </dd></dl>
<dlcompact><dt><b>Exceptions:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em><aclass="el"href="classxercesc_1_1DOMException.html">DOMException</a></em> </td><td>WRONG_DOCUMENT_ERR: Raised if <code>newAttr</code> was created from a different document than the one that created the element. <br>
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. <br>
INUSE_ATTRIBUTE_ERR: Raised if <code>newAttr</code> is already an attribute of another <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code> object. The DOM user must explicitly clone <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> nodes to re-use them in other elements. </td></tr>
If the removed <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix, when applicable.<p>
<tr><tdvalign="top"></td><tdvalign="top"><em>oldAttr</em> </td><td>The <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> node to remove from the attribute list. </td></tr>
<dlclass="return"compact><dt><b>Returns:</b></dt><dd>The <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> node that was removed. </dd></dl>
<tr><tdvalign="top"></td><tdvalign="top"><em><aclass="el"href="classxercesc_1_1DOMException.html">DOMException</a></em> </td><td>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. <br>
NOT_FOUND_ERR: Raised if <code>oldAttr</code> is not an attribute of the element. </td></tr>
If the removed attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.<br>
To remove an attribute by local name and namespace URI, use the <code>removeAttributeNS</code> method. <dlcompact><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>name</em> </td><td>The name of the attribute to remove. </td></tr>
</table>
</dl>
<dlcompact><dt><b>Exceptions:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em><aclass="el"href="classxercesc_1_1DOMException.html">DOMException</a></em> </td><td>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>namespaceURI</em> </td><td>The <em>namespace URI</em> of the attribute to retrieve. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>localName</em> </td><td>The <em>local name</em> of the attribute to retrieve. </td></tr>
</table>
</dl>
<dlclass="return"compact><dt><b>Returns:</b></dt><dd>The <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> value as a string, or an <code>null</code> if that attribute does not have a specified or default value. </dd></dl>
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 <code>qualifiedName</code>, and its value is changed to be the <code>value</code> 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 <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> node plus any <code><aclass="el"href="classxercesc_1_1DOMText.html">DOMText</a></code> and <code><aclass="el"href="classxercesc_1_1DOMEntityReference.html">DOMEntityReference</a></code> nodes, build the appropriate subtree, and use <code>setAttributeNodeNS</code> or <code>setAttributeNode</code> to assign it as the value of an attribute.<p>
<dlcompact><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>namespaceURI</em> </td><td>The <em>namespace URI</em> of the attribute to create or alter. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>qualifiedName</em> </td><td>The <em>qualified name</em> of the attribute to create or alter. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>value</em> </td><td>The value to set in string form. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em><aclass="el"href="classxercesc_1_1DOMException.html">DOMException</a></em> </td><td>INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character. <br>
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. <br>
NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is malformed, if the <code>qualifiedName</code> has a prefix and the <code>namespaceURI</code> is <code>null</code> or an empty string, if the <code>qualifiedName</code> has a prefix that is "xml" and the <code>namespaceURI</code> is different from "http://www.w3.org/XML/1998/namespace", if the <code>qualifiedName</code> has a prefix that is "xmlns" and the <code>namespaceURI</code> is different from "http://www.w3.org/2000/xmlns/", or if the <code>qualifiedName</code> is "xmlns" and the <code>namespaceURI</code> is different from "http://www.w3.org/2000/xmlns/". </td></tr>
Removes an attribute by local name and namespace URI.
<p>
If the removed attribute has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix.<p>
<dlcompact><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>namespaceURI</em> </td><td>The <em>namespace URI</em> of the attribute to remove. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>localName</em> </td><td>The <em>local name</em> of the attribute to remove. </td></tr>
</table>
</dl>
<dlcompact><dt><b>Exceptions:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em><aclass="el"href="classxercesc_1_1DOMException.html">DOMException</a></em> </td><td>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. </td></tr>
<dlclass="return"compact><dt><b>Returns:</b></dt><dd>The <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> node with the specified attribute local name and namespace URI or <code>null</code> if there is no such attribute. </dd></dl>
<tr><tdvalign="top"></td><tdvalign="top"><em>newAttr</em> </td><td>The <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> node to add to the attribute list. </td></tr>
<dlclass="return"compact><dt><b>Returns:</b></dt><dd>If the <code>newAttr</code> attribute replaces an existing attribute with the same <em>local name</em> and <em>namespace URI</em>, the replaced <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> node is returned, otherwise <code>null</code> is returned. </dd></dl>
<tr><tdvalign="top"></td><tdvalign="top"><em><aclass="el"href="classxercesc_1_1DOMException.html">DOMException</a></em> </td><td>WRONG_DOCUMENT_ERR: Raised if <code>newAttr</code> was created from a different document than the one that created the element. <br>
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. <br>
INUSE_ATTRIBUTE_ERR: Raised if <code>newAttr</code> is already an attribute of another <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code> object. The DOM user must explicitly clone <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> nodes to re-use them in other elements. </td></tr>
Returns a <code><aclass="el"href="classxercesc_1_1DOMNodeList.html">DOMNodeList</a></code> of all the <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code>s with a given local name and namespace URI in the order in which they would be encountered in a preorder traversal of the <code><aclass="el"href="classxercesc_1_1DOMDocument.html">DOMDocument</a></code> tree, starting from this node.
<tr><tdvalign="top"></td><tdvalign="top"><em>namespaceURI</em> </td><td>The <em>namespace URI</em> of the elements to match on. The special value "*" matches all namespaces. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>localName</em> </td><td>The <em>local name</em> of the elements to match on. The special value "*" matches all local names. </td></tr>
<dlclass="return"compact><dt><b>Returns:</b></dt><dd>A new <code><aclass="el"href="classxercesc_1_1DOMNodeList.html">DOMNodeList</a></code> object containing all the matched <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code>s. </dd></dl>
<dlclass="return"compact><dt><b>Returns:</b></dt><dd><code>true</code> if an attribute with the given name is specified on this element or has a default value, <code>false</code> otherwise. </dd></dl>
Returns <code>true</code> when an attribute with a given local name and namespace URI is specified on this element or has a default value, <code>false</code> otherwise.
<dlclass="return"compact><dt><b>Returns:</b></dt><dd><code>true</code> if an attribute with the given local name and namespace URI is specified or has a default value on this element, <code>false</code> otherwise. </dd></dl>
Declares the <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> specified by name to be of type ID.
<p>
If the value of the specified <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> is unique then this element node can later be retrieved using getElementById on Document. Note, however, that this simply affects this node and does not change any grammar that may be in use. To specify an <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> by local name and namespace URI, use the setIdAttributeNS method. <dlcompact><dt><b>Parameters:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em>name</em> </td><td>The name of the <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code>. </td></tr>
</table>
</dl>
<dlcompact><dt><b>Exceptions:</b></dt><dd>
<tableborder="0"cellspacing="2"cellpadding="0">
<tr><tdvalign="top"></td><tdvalign="top"><em><aclass="el"href="classxercesc_1_1DOMException.html">DOMException</a></em> </td><td>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. <br>
NOT_FOUND_ERR: Raised if the specified node is not an <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> of this element.</td></tr>
If the value of the specified <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> is unique then this <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code> node can later be retrieved using getElementById on <code><aclass="el"href="classxercesc_1_1DOMDocument.html">DOMDocument</a></code>. Note, however, that this simply affects this node and does not change any grammar that may be in use. <dlcompact><dt><b>Parameters:</b></dt><dd>
<tr><tdvalign="top"></td><tdvalign="top"><em>namespaceURI</em> </td><td>The namespace URI of the <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code>. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em>localName</em> </td><td>The local name of the <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code>. </td></tr>
<tr><tdvalign="top"></td><tdvalign="top"><em><aclass="el"href="classxercesc_1_1DOMException.html">DOMException</a></em> </td><td>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. <br>
NOT_FOUND_ERR: Raised if the specified node is not an <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> of this element.</td></tr>
If the value of the specified <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> is unique then this <code><aclass="el"href="classxercesc_1_1DOMElement.html">DOMElement</a></code> node can later be retrieved using getElementById on <code><aclass="el"href="classxercesc_1_1DOMDocument.html">DOMDocument</a></code>. Note, however, that this simply affects this node and does not change any grammar that may be in use. <dlcompact><dt><b>Parameters:</b></dt><dd>
<tr><tdvalign="top"></td><tdvalign="top"><em><aclass="el"href="classxercesc_1_1DOMException.html">DOMException</a></em> </td><td>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. <br>
NOT_FOUND_ERR: Raised if the specified node is not an <code><aclass="el"href="classxercesc_1_1DOMAttr.html">DOMAttr</a></code> of this element.</td></tr>
Returns the type information associated with this element.
<p>
<b>"Experimental - subject to change"</b><p>
<dlclass="return"compact><dt><b>Returns:</b></dt><dd>the <code><aclass="el"href="classxercesc_1_1DOMTypeInfo.html">DOMTypeInfo</a></code> associated with this element </dd></dl>