Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
getElementById vs querySelector v
(version: 0)
Test performance of different ways of get just one particular DOM element
Comparing performance of:
getElementById vs getElementsByTagName vs querySelector vs getElementsByClassName vs getElementsByName
Created:
7 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<body> <div class="navbar" align="center"><a accesskey="p" href="introduction.html">previous</a> <a accesskey="n" href="changes.html">next</a> <a accesskey="c" href="Overview.html#contents">contents</a> <a accesskey="i" href="def-index.html">index</a> <hr title="Navigation area separator"> </div> <div class="noprint" style="text-align: right"> <p style="font-family: monospace;font-size:small">13 November, 2000</p> </div> <div class="div1"><a id="Core" name="Core"></a> <h1 id="Core-h1" class="div1">1. Document Object Model Core</h1> <dl> <dt><i>Editors</i></dt> <dd>Arnaud Le Hors, IBM</dd> <dd>Gavin Nicol, Inso EPS (for DOM Level 1)</dd> <dd>Lauren Wood, SoftQuad, Inc. (for DOM Level 1)</dd> <dd>Mike Champion, ArborText (for DOM Level 1 from November 20, 1997)</dd> <dd>Steve Byrne, JavaSoft (for DOM Level 1 until November 19, 1997)</dd> </dl> <div class="noprint"> <h2 id="table-of-contents">Table of contents</h2> <ul class="toc"> <li class="tocline3"><a class="tocxref" href="#ID-1590626201">1.1. Overview of the DOM Core Interfaces</a> <ul class="toc"> <li class="tocline4"><a class="tocxref" href="#ID-1590626202">1.1.1. The DOM Structure Model</a></li> <li class="tocline4"><a class="tocxref" href="#ID-249F15BA">1.1.2. Memory Management</a></li> <li class="tocline4"><a class="tocxref" href="#ID-45A944CB">1.1.3. Naming Conventions</a></li> <li class="tocline4"><a class="tocxref" href="#ID-1CED5498">1.1.4. Inheritance vs. Flattened Views of the API</a></li> <li class="tocline4"><a class="tocxref" href="#ID-C74D1578">1.1.5. The DOMString type</a></li> <li class="tocline4"><a class="tocxref" href="#Core-DOMTimeStamp">1.1.6. The DOMTimeStamp type</a></li> <li class="tocline4"><a class="tocxref" href="#ID-5DFED1F0">1.1.7. String comparisons in the DOM</a></li> <li class="tocline4"><a class="tocxref" href="#Namespaces-Considerations">1.1.8. XML Namespaces</a></li> </ul> </li> <li class="tocline3"><a class="tocxref" href="#ID-BBACDC08">1.2. Fundamental Interfaces</a> <ul class="toc"> <li class="tocline4"><a href="#ID-17189187">DOMException</a>, <a href="#ID-258A00AF">ExceptionCode</a>, <a href="#ID-102161490">DOMImplementation</a>, <a href="#ID-B63ED1A3">DocumentFragment</a>, <a href="#i-Document">Document</a>, <a href="#ID-1950641247">Node</a>, <a href="#ID-536297177">NodeList</a>, <a href="#ID-1780488922">NamedNodeMap</a>, <a href="#ID-FF21A306">CharacterData</a>, <a href="#ID-637646024">Attr</a>, <a href="#ID-745549614">Element</a>, <a href="#ID-1312295772">Text</a>, <a href="#ID-1728279322">Comment</a></li> </ul> </li> <li class="tocline3"><a class="tocxref" href="#ID-E067D597">1.3. Extended Interfaces</a> <ul class="toc"> <li class="tocline4"><a href="#ID-667469212">CDATASection</a>, <a href="#ID-412266927">DocumentType</a>, <a href="#ID-5431D1B9">Notation</a>, <a href="#ID-527DCFF2">Entity</a>, <a href="#ID-11C98490">EntityReference</a>, <a href="#ID-1004215813">ProcessingInstruction</a></li> </ul> </li> </ul> </div> <div class="div2"><a id="ID-1590626201" name="ID-1590626201"></a> <h2 id="ID-1590626201-h2" class="div2">1.1. Overview of the DOM Core Interfaces</h2> <p>This section defines a set of objects and interfaces for accessing and manipulating document objects. The functionality specified in this section (the <em>Core</em> functionality) is sufficient to allow software developers and web script authors to access and manipulate parsed HTML and XML content inside conforming products. The DOM Core API also allows creation and population of a <a href="core.html#i-Document"><code>Document</code></a> object using only DOM API calls; loading a <a class="noxref" href="core.html#i-Document"><code>Document</code></a> and saving it persistently is left to the product that implements the DOM API.</p> <div class="div3"><a id="ID-1590626202" name="ID-1590626202"></a> <h3 id="ID-1590626202-h3" class="div3">1.1.1. The DOM Structure Model</h3> <p>The DOM presents documents as a hierarchy of <a href="core.html#ID-1950641247"><code>Node</code></a> objects that also implement other, more specialized interfaces. Some types of nodes may have <a href="glossary.html#dt-child"><em>child</em></a> nodes of various types, and others are leaf nodes that cannot have anything below them in the document structure. For XML and HTML, the node types, and which node types they may have as children, are as follows:</p> <ul> <li><a href="core.html#i-Document"><code>Document</code></a> -- <a href="core.html#ID-745549614"><code>Element</code></a> (maximum of one), <a href="core.html#ID-1004215813"><code>ProcessingInstruction</code></a>, <a href="core.html#ID-1728279322"><code>Comment</code></a>, <a href="core.html#ID-412266927"><code>DocumentType</code></a> (maximum of one)</li> <li><a href="core.html#ID-B63ED1A3"><code>DocumentFragment</code></a> -- <a href="core.html#ID-745549614"><code>Element</code></a>, <a href="core.html#ID-1004215813"><code>ProcessingInstruction</code></a>, <a href="core.html#ID-1728279322"><code>Comment</code></a>, <a href="core.html#ID-1312295772"><code>Text</code></a>, <a href="core.html#ID-667469212"><code>CDATASection</code></a>, <a href="core.html#ID-11C98490"><code>EntityReference</code></a></li> <li><a href="core.html#ID-412266927"><code>DocumentType</code></a> -- no children</li> <li><a href="core.html#ID-11C98490"><code>EntityReference</code></a> -- <a href="core.html#ID-745549614"><code>Element</code></a>, <a href="core.html#ID-1004215813"><code>ProcessingInstruction</code></a>, <a href="core.html#ID-1728279322"><code>Comment</code></a>, <a href="core.html#ID-1312295772"><code>Text</code></a>, <a href="core.html#ID-667469212"><code>CDATASection</code></a>, <a class="noxref" href="core.html#ID-11C98490"><code>EntityReference</code></a></li> <li><a href="core.html#ID-745549614"><code>Element</code></a> -- <a class="noxref" href="core.html#ID-745549614"><code>Element</code></a>, <a href="core.html#ID-1312295772"><code>Text</code></a>, <a href="core.html#ID-1728279322"><code>Comment</code></a>, <a href="core.html#ID-1004215813"><code>ProcessingInstruction</code></a>, <a href="core.html#ID-667469212"><code>CDATASection</code></a>, <a href="core.html#ID-11C98490"><code>EntityReference</code></a></li> <li><a href="core.html#ID-637646024"><code>Attr</code></a> -- <a href="core.html#ID-1312295772"><code>Text</code></a>, <a href="core.html#ID-11C98490"><code>EntityReference</code></a></li> <li><a href="core.html#ID-1004215813"><code>ProcessingInstruction</code></a> -- no children</li> <li><a href="core.html#ID-1728279322"><code>Comment</code></a> -- no children</li> <li><a href="core.html#ID-1312295772"><code>Text</code></a> -- no children</li> <li><a href="core.html#ID-667469212"><code>CDATASection</code></a> -- no children</li> <li><a href="core.html#ID-527DCFF2"><code>Entity</code></a> -- <a href="core.html#ID-745549614"><code>Element</code></a>, <a href="core.html#ID-1004215813"><code>ProcessingInstruction</code></a>, <a href="core.html#ID-1728279322"><code>Comment</code></a>, <a href="core.html#ID-1312295772"><code>Text</code></a>, <a href="core.html#ID-667469212"><code>CDATASection</code></a>, <a href="core.html#ID-11C98490"><code>EntityReference</code></a></li> <li><a href="core.html#ID-5431D1B9"><code>Notation</code></a> -- no children</li> </ul> <p>The DOM also specifies a <a href="core.html#ID-536297177"><code>NodeList</code></a> interface to handle ordered lists of <a href="core.html#ID-1950641247"><code>Nodes</code></a>, such as the children of a <a href="core.html#ID-1950641247"><code>Node</code></a>, or the <a href="glossary.html#dt-element"><em>elements</em></a> returned by the <code>getElementsByTagName</code> method of the <a href="core.html#ID-745549614"><code>Element</code></a> interface, and also a <a href="core.html#ID-1780488922"><code>NamedNodeMap</code></a> interface to handle unordered sets of nodes referenced by their name attribute, such as the attributes of an <a class="noxref" href="core.html#ID-745549614"><code>Element</code></a>. <a id="td-live" name="td-live"></a> <a href="core.html#ID-536297177"><code>NodeList</code></a> and <a href="core.html#ID-1780488922"><code>NamedNodeMap</code></a> objects in the DOM are <i>live</i>; that is, changes to the underlying document structure are reflected in all relevant <a class="noxref" href="core.html#ID-536297177"><code>NodeList</code></a> and <a class="noxref" href="core.html#ID-1780488922"><code>NamedNodeMap</code></a> objects. For example, if a DOM user gets a <a class="noxref" href="core.html#ID-536297177"><code>NodeList</code></a> object containing the children of an <a href="core.html#ID-745549614"><code>Element</code></a>, then subsequently adds more children to that <a href="glossary.html#dt-element"><em>element</em></a> (or removes children, or modifies them), those changes are automatically reflected in the <a class="noxref" href="core.html#ID-536297177"><code>NodeList</code></a>, without further action on the user's part. Likewise, changes to a <a href="core.html#ID-1950641247"><code>Node</code></a> in the tree are reflected in all references to that <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a> in <a class="noxref" href="core.html#ID-536297177"><code>NodeList</code></a> and <a class="noxref" href="core.html#ID-1780488922"><code>NamedNodeMap</code></a> objects.</p> <p>Finally, the interfaces <a href="core.html#ID-1312295772"><code>Text</code></a>, <a href="core.html#ID-1728279322"><code>Comment</code></a>, and <a href="core.html#ID-667469212"><code>CDATASection</code></a> all inherit from the <a href="core.html#ID-FF21A306"><code>CharacterData</code></a> interface.</p> </div> <!-- div3 ID-1590626202 --> <div class="div3"><a id="ID-249F15BA" name="ID-249F15BA"></a> <h3 id="ID-249F15BA-h3" class="div3">1.1.2. Memory Management</h3> <p>Most of the APIs defined by this specification are <em>interfaces</em> rather than classes. That means that an implementation need only expose methods with the defined names and specified operation, not implement classes that correspond directly to the interfaces. This allows the DOM APIs to be implemented as a thin veneer on top of legacy applications with their own data structures, or on top of newer applications with different class hierarchies. This also means that ordinary constructors (in the Java or C++ sense) cannot be used to create DOM objects, since the underlying objects to be constructed may have little relationship to the DOM interfaces. The conventional solution to this in object-oriented design is to define <em>factory</em> methods that create instances of objects that implement the various interfaces. Objects implementing some interface "X" are created by a "createX()" method on the <a href="core.html#i-Document"><code>Document</code></a> interface; this is because all DOM objects live in the context of a specific Document.</p> <p>The DOM Level 2 API does <em>not</em> define a standard way to create <a href="core.html#ID-102161490"><code>DOMImplementation</code></a> objects; DOM implementations must provide some proprietary way of bootstrapping these DOM interfaces, and then all other objects can be built from there.</p> <p>The Core DOM APIs are designed to be compatible with a wide range of languages, including both general-user scripting languages and the more challenging languages used mostly by professional programmers. Thus, the DOM APIs need to operate across a variety of memory management philosophies, from language bindings that do not expose memory management to the user at all, through those (notably Java) that provide explicit constructors but provide an automatic garbage collection mechanism to automatically reclaim unused memory, to those (especially C/C++) that generally require the programmer to explicitly allocate object memory, track where it is used, and explicitly free it for re-use. To ensure a consistent API across these platforms, the DOM does not address memory management issues at all, but instead leaves these for the implementation. Neither of the explicit language bindings defined by the DOM API (for <a href="glossary.html#dt-ECMAScript"><em>ECMAScript</em></a> and Java) require any memory management methods, but DOM bindings for other languages (especially C or C++) may require such support. These extensions will be the responsibility of those adapting the DOM API to a specific language, not the DOM Working Group.</p> </div> <!-- div3 ID-249F15BA --> <div class="div3"><a id="ID-45A944CB" name="ID-45A944CB"></a> <h3 id="ID-45A944CB-h3" class="div3">1.1.3. Naming Conventions</h3> <p>While it would be nice to have attribute and method names that are short, informative, internally consistent, and familiar to users of similar APIs, the names also should not clash with the names in legacy APIs supported by DOM implementations. Furthermore, both OMG IDL and <code>ECMAScript</code> have significant limitations in their ability to disambiguate names from different namespaces that make it difficult to avoid naming conflicts with short, familiar names. So, DOM names tend to be long and descriptive in order to be unique across all environments.</p> <p>The Working Group has also attempted to be internally consistent in its use of various terms, even though these may not be common distinctions in other APIs. For example, the DOM API uses the method name "remove" when the method changes the structural model, and the method name "delete" when the method gets rid of something inside the structure model. The thing that is deleted is not returned. The thing that is removed may be returned, when it makes sense to return it.</p> </div> <!-- div3 ID-45A944CB --> <div class="div3"><a id="ID-1CED5498" name="ID-1CED5498"></a> <h3 id="ID-1CED5498-h3" class="div3">1.1.4. Inheritance vs. Flattened Views of the API</h3> <p>The DOM Core <a href="glossary.html#dt-API"><em>APIs</em></a> present two somewhat different sets of interfaces to an XML/HTML document: one presenting an "object oriented" approach with a hierarchy of <a href="glossary.html#dt-inheritance"><em>inheritance</em></a>, and a "simplified" view that allows all manipulation to be done via the <a href="core.html#ID-1950641247"><code>Node</code></a> interface without requiring casts (in Java and other C-like languages) or query interface calls in <a href="glossary.html#dt-COM"><em>COM</em></a> environments. These operations are fairly expensive in Java and COM, and the DOM may be used in performance-critical environments, so we allow significant functionality using just the <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a> interface. Because many other users will find the <a href="glossary.html#dt-inheritance"><em>inheritance</em></a> hierarchy easier to understand than the "everything is a <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a>" approach to the DOM, we also support the full higher-level interfaces for those who prefer a more object-oriented <a href="glossary.html#dt-API"><em>API</em></a>.</p> <p>In practice, this means that there is a certain amount of redundancy in the <a href="glossary.html#dt-API"><em>API</em></a>. The Working Group considers the "<a href="glossary.html#dt-inheritance"><em>inheritance</em></a>" approach the primary view of the API, and the full set of functionality on <a href="core.html#ID-1950641247"><code>Node</code></a> to be "extra" functionality that users may employ, but that does not eliminate the need for methods on other interfaces that an object-oriented analysis would dictate. (Of course, when the O-O analysis yields an attribute or method that is identical to one on the <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a> interface, we don't specify a completely redundant one.) Thus, even though there is a generic <code>nodeName</code> attribute on the <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a> interface, there is still a <code>tagName</code> attribute on the <a href="core.html#ID-745549614"><code>Element</code></a> interface; these two attributes must contain the same value, but the it is worthwhile to support both, given the different constituencies the DOM <a href="glossary.html#dt-API"><em>API</em></a> must satisfy.</p> </div> <!-- div3 ID-1CED5498 --> <div class="div3"><a id="ID-C74D1578" name="ID-C74D1578"></a> <h3 id="ID-C74D1578-h3" class="div3">1.1.5. The <a href="core.html#DOMString"><code>DOMString</code></a> type</h3> <p>To ensure interoperability, the DOM specifies the following:</p> <ul> <li> <dl> <dt><b>Type Definition <i><a id="DOMString" name="DOMString">DOMString</a></i></b></dt> <dd> <p>A <a href="core.html#DOMString"><code>DOMString</code></a> is a sequence of <a href="glossary.html#dt-16-bit-unit"><em>16-bit units</em></a>.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>valuetype DOMString sequence<unsigned short>; </pre> </div> <br> </dd> </dl> </dd> </dl> </li> <li>Applications must encode <a href="core.html#DOMString"><code>DOMString</code></a> using UTF-16 (defined in [<a class="noxref" href="references.html#Unicode">Unicode</a>] and Amendment 1 of [<a class="noxref" href="references.html#ISO10646">ISO/IEC 10646</a>]).<br> The UTF-16 encoding was chosen because of its widespread industry practice. Note that for both HTML and XML, the document character set (and therefore the notation of numeric character references) is based on UCS [ISO-10646]. A single numeric character reference in a source document may therefore in some cases correspond to two 16-bit units in a <a href="core.html#DOMString"><code>DOMString</code></a> (a high surrogate and a low surrogate). <p><b>Note:</b> Even though the DOM defines the name of the string type to be <a href="core.html#DOMString"><code>DOMString</code></a>, bindings may use different names. For example for Java, <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a> is bound to the <code>String</code> type because it also uses UTF-16 as its encoding.</p> </li> </ul> <p><b>Note:</b> As of August 2000, the OMG IDL specification ([<a class="noxref" href="references.html#OMGIDL">OMGIDL</a>]) included a <code>wstring</code> type. However, that definition did not meet the interoperability criteria of the DOM <a href="glossary.html#dt-API"><em>API</em></a> since it relied on negotiation to decide the width and encoding of a character.</p> </div> <!-- div3 ID-C74D1578 --> <div class="div3"><a id="Core-DOMTimeStamp" name="Core-DOMTimeStamp"></a> <h3 id="Core-DOMTimeStamp-h3" class="div3">1.1.6. The <a href="core.html#DOMTimeStamp"><code>DOMTimeStamp</code></a> type</h3> <p>To ensure interoperability, the DOM specifies the following:</p> <ul> <li> <dl> <dt><b>Type Definition <i><a id="DOMTimeStamp" name="DOMTimeStamp">DOMTimeStamp</a></i></b></dt> <dd> <p>A <a href="core.html#DOMTimeStamp"><code>DOMTimeStamp</code></a> represents a number of milliseconds.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>typedef unsigned long long DOMTimeStamp; </pre> </div> <br> </dd> </dl> </dd> </dl> </li> <li> <p><b>Note:</b> Even though the DOM uses the type <a href="core.html#DOMTimeStamp"><code>DOMTimeStamp</code></a>, bindings may use different types. For example for Java, <a class="noxref" href="core.html#DOMTimeStamp"><code>DOMTimeStamp</code></a> is bound to the <code>long</code> type. In ECMAScript, <code>TimeStamp</code> is bound to the <code>Date</code> type because the range of the <code>integer</code> type is too small.</p> </li> </ul> </div> <!-- div3 Core-DOMTimeStamp --> <div class="div3"><a id="ID-5DFED1F0" name="ID-5DFED1F0"></a> <h3 id="ID-5DFED1F0-h3" class="div3">1.1.7. String comparisons in the DOM</h3> <p>The DOM has many interfaces that imply string matching. HTML processors generally assume an uppercase (less often, lowercase) normalization of names for such things as <a href="glossary.html#dt-element"><em>elements</em></a>, while XML is explicitly case sensitive. For the purposes of the DOM, string matching is performed purely by binary <a href="glossary.html#dt-string-compare"><em>comparison</em></a> of the <a href="glossary.html#dt-16-bit-unit"><em>16-bit units</em></a> of the <a href="core.html#DOMString"><code>DOMString</code></a>. In addition, the DOM assumes that any case normalizations take place in the processor, <em>before</em> the DOM structures are built.</p> <p><b>Note:</b> Besides case folding, there are additional normalizations that can be applied to text. The W3C I18N Working Group is in the process of defining exactly which normalizations are necessary, and where they should be applied. The W3C I18N Working Group expects to require early normalization, which means that data read into the DOM is assumed to already be normalized. The DOM and applications built on top of it in this case only have to assure that text remains normalized when being changed. For further details, please see [<a class="noxref" href="references.html#Charmod">Charmod</a>].</p> </div> <!-- div3 ID-5DFED1F0 --> <div class="div3"><a id="Namespaces-Considerations" name="Namespaces-Considerations"></a> <h3 id="Namespaces-Considerations-h3" class="div3">1.1.8. XML Namespaces</h3> <p>The DOM Level 2 supports XML namespaces [<a class="noxref" href="references.html#Namespaces">Namespaces</a>] by augmenting several interfaces of the DOM Level 1 Core to allow creating and manipulating <a href="glossary.html#dt-element"><em>elements</em></a> and attributes associated to a namespace.</p> <p>As far as the DOM is concerned, special attributes used for declaring <a href="glossary.html#dt-XML-namespace"><em>XML namespaces</em></a> are still exposed and can be manipulated just like any other attribute. However, nodes are permanently bound to <a href="glossary.html#dt-namespaceURI"><em>namespace URIs</em></a> as they get created. Consequently, moving a node within a document, using the DOM, in no case results in a change of its <a href="glossary.html#dt-namespaceprefix"><em>namespace prefix</em></a> or namespace URI. Similarly, creating a node with a namespace prefix and namespace URI, or changing the namespace prefix of a node, does not result in any addition, removal, or modification of any special attributes for declaring the appropriate XML namespaces. Namespace validation is not enforced; the DOM application is responsible. In particular, since the mapping between prefixes and namespace URIs is not enforced, in general, the resulting document cannot be serialized naively. For example, applications may have to declare every namespace in use when serializing a document.</p> <p>DOM Level 2 doesn't perform any URI normalization or canonicalization. The URIs given to the DOM are assumed to be valid (e.g., characters such as whitespaces are properly escaped), and no lexical checking is performed. Absolute URI references are treated as strings and <a href="glossary.html#dt-string-compare"><em>compared literally</em></a>. How relative namespace URI references are treated is undefined. To ensure interoperability only absolute namespace URI references (i.e., URI references beginning with a scheme name and a colon) should be used. Note that because the DOM does no lexical checking, the empty string will be treated as a real namespace URI in DOM Level 2 methods. Applications must use the value <code>null</code> as the namespaceURI parameter for methods if they wish to have no namespace.</p> <p><b>Note:</b> In the DOM, all namespace declaration attributes are <em>by definition</em> bound to the namespace URI: "<a href="http://www.w3.org/2000/xmlns/">http://www.w3.org/2000/xmlns/</a>". These are the attributes whose <a href="glossary.html#dt-namespaceprefix"><em>namespace prefix</em></a> or <a href="glossary.html#dt-qualifiedname"><em>qualified name</em></a> is "xmlns". Although, at the time of writing, this is not part of the XML Namespaces specification [<a class="noxref" href="references.html#Namespaces">Namespaces</a>], it is planned to be incorporated in a future revision.</p> <p>In a document with no namespaces, the <a href="glossary.html#dt-child"><em>child</em></a> list of an <a href="core.html#ID-11C98490"><code>EntityReference</code></a> node is always the same as that of the corresponding <a href="core.html#ID-527DCFF2"><code>Entity</code></a>. This is not true in a document where an entity contains unbound <a href="glossary.html#dt-namespaceprefix"><em>namespace prefixes</em></a>. In such a case, the <a href="glossary.html#dt-descendant"><em>descendants</em></a> of the corresponding <a class="noxref" href="core.html#ID-11C98490"><code>EntityReference</code></a> nodes may be bound to different <a href="glossary.html#dt-namespaceURI"><em>namespace URIs</em></a>, depending on where the entity references are. Also, because, in the DOM, nodes always remain bound to the same namespace URI, moving such <a class="noxref" href="core.html#ID-11C98490"><code>EntityReference</code></a> nodes can lead to documents that cannot be serialized. This is also true when the DOM Level 1 method <code>createEntityReference</code> of the <a href="core.html#i-Document"><code>Document</code></a> interface is used to create entity references that correspond to such entities, since the <a href="glossary.html#dt-descendant"><em>descendants</em></a> of the returned <a class="noxref" href="core.html#ID-11C98490"><code>EntityReference</code></a> are unbound. The DOM Level 2 does not support any mechanism to resolve namespace prefixes. For all of these reasons, use of such entities and entity references should be avoided or used with extreme care. A future Level of the DOM may include some additional support for handling these.</p> <p>The new methods, such as <code>createElementNS</code> and <code>createAttributeNS</code> of the <a href="core.html#i-Document"><code>Document</code></a> interface, are meant to be used by namespace aware applications. Simple applications that do not use namespaces can use the DOM Level 1 methods, such as <code>createElement</code> and <code>createAttribute</code>. Elements and attributes created in this way do not have any namespace prefix, namespace URI, or local name.</p> <p><b>Note:</b> DOM Level 1 methods are namespace ignorant. Therefore, while it is safe to use these methods when not dealing with namespaces, using them and the new ones at the same time should be avoided. DOM Level 1 methods solely identify attribute nodes by their <code>nodeName</code>. On the contrary, the DOM Level 2 methods related to namespaces, identify attribute nodes by their <code>namespaceURI</code> and <code>localName</code>. Because of this fundamental difference, mixing both sets of methods can lead to unpredictable results. In particular, using <code>setAttributeNS</code>, an <a href="glossary.html#dt-element"><em>element</em></a> may have two attributes (or more) that have the same <code>nodeName</code>, but different <code>namespaceURI</code>s. Calling <code>getAttribute</code> with that <code>nodeName</code> could then return any of those attributes. The result depends on the implementation. Similarly, using <code>setAttributeNode</code>, one can set two attributes (or more) that have different <code>nodeNames</code> but the same <code>prefix</code> and <code>namespaceURI</code>. In this case <code>getAttributeNodeNS</code> will return either attribute, in an implementation dependent manner. The only guarantee in such cases is that all methods that access a named item by its <code>nodeName</code> will access the same item, and all methods which access a node by its URI and local name will access the same node. For instance, <code>setAttribute</code> and <code>setAttributeNS</code> affect the node that <code>getAttribute</code> and <code>getAttributeNS</code>, respectively, return.</p> </div> <!-- div3 Namespaces-Considerations --></div> <!-- div2 ID-1590626201 --> <div class="div2"><a id="ID-BBACDC08" name="ID-BBACDC08"></a> <h2 id="ID-BBACDC08-h2" class="div2">1.2. Fundamental Interfaces</h2> <p>The interfaces within this section are considered <em>fundamental</em>, and must be fully implemented by all conforming implementations of the DOM, including all HTML DOM implementations [<a class="noxref" href="references.html#DOMHTML-inf">DOM Level 2 HTML</a>], unless otherwise specified.</p> <p>A DOM application may use the <code>hasFeature(feature, version)</code> method of the <a href="core.html#ID-102161490"><code>DOMImplementation</code></a> interface with parameter values "Core" and "2.0" (respectively) to determine whether or not this module is supported by the implementation. Any implementation that conforms to DOM Level 2 or a DOM Level 2 module must conform to the Core module. Please refer to additional information about <a href="http://www.w3.org/TR/DOM-Level-2-Core/introduction.html#ID-Conformance"> <em>conformance</em></a> in this specification.</p> <dl> <dt><b>Exception <i><a id="ID-17189187" name="ID-17189187">DOMException</a></i></b></dt> <dd> <p>DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impossible to perform (either for logical reasons, because data is lost, or because the implementation has become unstable). In general, DOM methods return specific error values in ordinary processing situations, such as out-of-bound errors when using <a href="core.html#ID-536297177"><code>NodeList</code></a>.</p> <p>Implementations should raise other exceptions under other circumstances. For example, implementations should raise an implementation-dependent exception if a <code>null</code> argument is passed.</p> <p>Some languages and object systems do not support the concept of exceptions. For such systems, error conditions may be indicated using native error reporting mechanisms. For some bindings, for example, methods may return error codes similar to those listed in the corresponding method descriptions.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>exception DOMException { unsigned short code; }; // ExceptionCode const unsigned short INDEX_SIZE_ERR = 1; const unsigned short DOMSTRING_SIZE_ERR = 2; const unsigned short HIERARCHY_REQUEST_ERR = 3; const unsigned short WRONG_DOCUMENT_ERR = 4; const unsigned short INVALID_CHARACTER_ERR = 5; const unsigned short NO_DATA_ALLOWED_ERR = 6; const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7; const unsigned short NOT_FOUND_ERR = 8; const unsigned short NOT_SUPPORTED_ERR = 9; const unsigned short INUSE_ATTRIBUTE_ERR = 10; // Introduced in DOM Level 2: const unsigned short INVALID_STATE_ERR = 11; // Introduced in DOM Level 2: const unsigned short SYNTAX_ERR = 12; // Introduced in DOM Level 2: const unsigned short INVALID_MODIFICATION_ERR = 13; // Introduced in DOM Level 2: const unsigned short NAMESPACE_ERR = 14; // Introduced in DOM Level 2: const unsigned short INVALID_ACCESS_ERR = 15; </pre> </div> <br> </dd> <dt><b>Definition group <i><a id="ID-258A00AF" name="ID-258A00AF">ExceptionCode</a></i></b></dt> <dd> <p>An integer indicating the type of error generated.</p> <p><b>Note:</b> Other numeric codes are reserved for W3C for possible future use.</p> <dl> <dt><b>Defined Constants</b></dt> <dd> <dl> <dt><code class="constant-name">DOMSTRING_SIZE_ERR</code></dt> <dd>If the specified range of text does not fit into a DOMString</dd> <dt><code class="constant-name">HIERARCHY_REQUEST_ERR</code></dt> <dd>If any node is inserted somewhere it doesn't belong</dd> <dt><code class="constant-name">INDEX_SIZE_ERR</code></dt> <dd>If index or size is negative, or greater than the allowed value</dd> <dt><code class="constant-name">INUSE_ATTRIBUTE_ERR</code></dt> <dd>If an attempt is made to add an attribute that is already in use elsewhere</dd> <dt><code class="constant-name">INVALID_ACCESS_ERR</code>, introduced in <b class="version">DOM Level 2</b>.</dt> <dd>If a parameter or an operation is not supported by the underlying object.</dd> <dt><code class="constant-name">INVALID_CHARACTER_ERR</code></dt> <dd>If an invalid or illegal character is specified, such as in a name. See <a href="http://www.w3.org/TR/1998/REC-xml-19980210#NT-Char"><em>production 2</em></a> in the XML specification for the definition of a legal character, and <a href="http://www.w3.org/TR/1998/REC-xml-19980210#NT-Name"><em>production 5</em></a> for the definition of a legal name character.</dd> <dt><code class="constant-name">INVALID_MODIFICATION_ERR</code>, introduced in <b class="version">DOM Level 2</b>.</dt> <dd>If an attempt is made to modify the type of the underlying object.</dd> <dt><code class="constant-name">INVALID_STATE_ERR</code>, introduced in <b class="version">DOM Level 2</b>.</dt> <dd>If an attempt is made to use an object that is not, or is no longer, usable.</dd> <dt><code class="constant-name">NAMESPACE_ERR</code>, introduced in <b class="version">DOM Level 2</b>.</dt> <dd>If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces.</dd> <dt><code class="constant-name">NOT_FOUND_ERR</code></dt> <dd>If an attempt is made to reference a node in a context where it does not exist</dd> <dt><code class="constant-name">NOT_SUPPORTED_ERR</code></dt> <dd>If the implementation does not support the requested type of object or operation.</dd> <dt><code class="constant-name">NO_DATA_ALLOWED_ERR</code></dt> <dd>If data is specified for a node which does not support data</dd> <dt><code class="constant-name">NO_MODIFICATION_ALLOWED_ERR</code></dt> <dd>If an attempt is made to modify an object where modifications are not allowed</dd> <dt><code class="constant-name">SYNTAX_ERR</code>, introduced in <b class="version">DOM Level 2</b>.</dt> <dd>If an invalid or illegal string is specified.</dd> <dt><code class="constant-name">WRONG_DOCUMENT_ERR</code></dt> <dd>If a node is used in a different document than the one that created it (that doesn't support it)</dd> </dl> </dd> </dl> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-102161490" name="ID-102161490">DOMImplementation</a></i></b></dt> <dd> <p>The <code>DOMImplementation</code> interface provides a number of methods for performing operations that are independent of any particular instance of the document object model.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface DOMImplementation { boolean hasFeature(in DOMString feature, in DOMString version); // Introduced in DOM Level 2: DocumentType createDocumentType(in DOMString qualifiedName, in DOMString publicId, in DOMString systemId) raises(DOMException); // Introduced in DOM Level 2: Document createDocument(in DOMString namespaceURI, in DOMString qualifiedName, in DocumentType doctype) raises(DOMException); }; </pre> </div> <br> </dd> <dt><b>Methods</b></dt> <dd> <dl> <dt><code class="method-name"><a id="Level-2-Core-DOM-createDocument" name="Level-2-Core-DOM-createDocument">createDocument</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Creates an XML <a href="core.html#i-Document"><code>Document</code></a> object of the specified type with its document element. HTML-only DOM implementations do not need to implement this method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">namespaceURI</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-namespaceURI"><em>namespace URI</em></a> of the document element to create.<br> </dd> <dt><code class="parameter-name">qualifiedName</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-qualifiedname"><em>qualified name</em></a> of the document element to be created.<br> </dd> <dt><code class="parameter-name">doctype</code> of type <a href="core.html#ID-412266927"><code>DocumentType</code></a></dt> <dd>The type of document to be created or <code>null</code>.<br> When <code>doctype</code> is not <code>null</code>, its <a href="core.html#node-ownerDoc"><code>Node.ownerDocument</code></a> attribute is set to the document being created.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#i-Document"><code>Document</code></a></p> </td> <td> <p>A new <a class="noxref" href="core.html#i-Document"><code>Document</code></a> object.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.</p> <p>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 if the <code>qualifiedName</code> has a prefix that is "xml" and the <code>namespaceURI</code> is different from "<a href="http://www.w3.org/XML/1998/namespace">http://www.w3.org/XML/1998/namespace</a>" [<a class="noxref" href="references.html#Namespaces">Namespaces</a>].</p> <p>WRONG_DOCUMENT_ERR: Raised if <code>doctype</code> has already been used with a different document or was created from a different implementation.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="Level-2-Core-DOM-createDocType" name="Level-2-Core-DOM-createDocType">createDocumentType</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Creates an empty <a href="core.html#ID-412266927"><code>DocumentType</code></a> node. Entity declarations and notations are not made available. Entity reference expansions and default attribute additions do not occur. It is expected that a future version of the DOM will provide a way for populating a <a class="noxref" href="core.html#ID-412266927"><code>DocumentType</code></a>.<br> HTML-only DOM implementations do not need to implement this method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">qualifiedName</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-qualifiedname"><em>qualified name</em></a> of the document type to be created.<br> </dd> <dt><code class="parameter-name">publicId</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The external subset public identifier.<br> </dd> <dt><code class="parameter-name">systemId</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The external subset system identifier.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-412266927"><code>DocumentType</code></a></p> </td> <td> <p>A new <a class="noxref" href="core.html#ID-412266927"><code>DocumentType</code></a> node with <a href="core.html#node-ownerDoc"><code>Node.ownerDocument</code></a> set to <code>null</code>.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.</p> <p>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is malformed.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-5CED94D7" name="ID-5CED94D7">hasFeature</a></code></dt> <dd> <div class="method">Test if the DOM implementation implements a specific feature. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">feature</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The name of the feature to test (case-insensitive). The values used by DOM features are defined throughout the DOM Level 2 specifications and listed in the <a href="introduction.html#ID-Conformance">Conformance</a> section. The name must be an <a href="glossary.html#dt-XML-name"><em>XML name</em></a>. To avoid possible conflicts, as a convention, names referring to features defined outside the DOM specification should be made unique by reversing the name of the Internet domain name of the person (or the organization that the person belongs to) who defines the feature, component by component, and using this as a prefix. For instance, the W3C SVG Working Group defines the feature "org.w3c.dom.svg".<br> </dd> <dt><code class="parameter-name">version</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>This is the version number of the feature to test. In Level 2, the string can be either "2.0" or "1.0". If the version is not specified, supporting any version of the feature causes the method to return <code>true</code>.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><code>boolean</code></p> </td> <td> <p><code>true</code> if the feature is implemented in the specified version, <code>false</code> otherwise.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> </dl> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-B63ED1A3" name="ID-B63ED1A3">DocumentFragment</a></i></b></dt> <dd> <p><code>DocumentFragment</code> is a "lightweight" or "minimal" <a href="core.html#i-Document"><code>Document</code></a> object. It is very common to want to be able to extract a portion of a document's tree or to create a new fragment of a document. Imagine implementing a user command like cut or rearranging a document by moving fragments around. It is desirable to have an object which can hold such fragments and it is quite natural to use a Node for this purpose. While it is true that a <a class="noxref" href="core.html#i-Document"><code>Document</code></a> object could fulfill this role, a <a class="noxref" href="core.html#i-Document"><code>Document</code></a> object can potentially be a heavyweight object, depending on the underlying implementation. What is really needed for this is a very lightweight object. <code>DocumentFragment</code> is such an object.</p> <p>Furthermore, various operations -- such as inserting nodes as children of another <a href="core.html#ID-1950641247"><code>Node</code></a> -- may take <code>DocumentFragment</code> objects as arguments; this results in all the child nodes of the <code>DocumentFragment</code> being moved to the child list of this node.</p> <p>The children of a <code>DocumentFragment</code> node are zero or more nodes representing the tops of any sub-trees defining the structure of the document. <code>DocumentFragment</code> nodes do not need to be <a href="glossary.html#dt-well-formed"><em>well-formed XML documents</em></a> (although they do need to follow the rules imposed upon well-formed XML parsed entities, which can have multiple top nodes). For example, a <code>DocumentFragment</code> might have only one child and that child node could be a <a href="core.html#ID-1312295772"><code>Text</code></a> node. Such a structure model represents neither an HTML document nor a well-formed XML document.</p> <p>When a <code>DocumentFragment</code> is inserted into a <a href="core.html#i-Document"><code>Document</code></a> (or indeed any other <a href="core.html#ID-1950641247"><code>Node</code></a> that may take children) the children of the <code>DocumentFragment</code> and not the <code>DocumentFragment</code> itself are inserted into the <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a>. This makes the <code>DocumentFragment</code> very useful when the user wishes to create nodes that are <a href="glossary.html#dt-sibling"><em>siblings</em></a>; the <code>DocumentFragment</code> acts as the parent of these nodes so that the user can use the standard methods from the <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a> interface, such as <code>insertBefore</code> and <code>appendChild</code>.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface DocumentFragment : Node { }; </pre> </div> <br> </dd> </dl> </dd> <dt><b>Interface <i><a id="i-Document" name="i-Document">Document</a></i></b></dt> <dd> <p>The <code>Document</code> interface represents the entire HTML or XML document. Conceptually, it is the <a href="glossary.html#dt-root-node"><em>root</em></a> of the document tree, and provides the primary access to the document's data.</p> <p>Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a <code>Document</code>, the <code>Document</code> interface also contains the factory methods needed to create these objects. The <a href="core.html#ID-1950641247"><code>Node</code></a> objects created have a <code>ownerDocument</code> attribute which associates them with the <code>Document</code> within whose context they were created.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface Document : Node { readonly attribute DocumentType doctype; readonly attribute DOMImplementation implementation; readonly attribute Element documentElement; Element createElement(in DOMString tagName) raises(DOMException); DocumentFragment createDocumentFragment(); Text createTextNode(in DOMString data); Comment createComment(in DOMString data); CDATASection createCDATASection(in DOMString data) raises(DOMException); ProcessingInstruction createProcessingInstruction(in DOMString target, in DOMString data) raises(DOMException); Attr createAttribute(in DOMString name) raises(DOMException); EntityReference createEntityReference(in DOMString name) raises(DOMException); NodeList getElementsByTagName(in DOMString tagname); // Introduced in DOM Level 2: Node importNode(in Node importedNode, in boolean deep) raises(DOMException); // Introduced in DOM Level 2: Element createElementNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); // Introduced in DOM Level 2: Attr createAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); // Introduced in DOM Level 2: NodeList getElementsByTagNameNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: Element getElementById(in DOMString elementId); }; </pre> </div> <br> </dd> <dt><b>Attributes</b></dt> <dd> <dl> <dt><code class="attribute-name"><a id="ID-B63ED1A31" name="ID-B63ED1A31">doctype</a></code> of type <a href="core.html#ID-412266927"><code>DocumentType</code></a>, readonly</dt> <dd>The Document Type Declaration (see <a href="core.html#ID-412266927"><code>DocumentType</code></a>) associated with this document. For HTML documents as well as XML documents without a document type declaration this returns <code>null</code>. The DOM Level 2 does not support editing the Document Type Declaration. <code>docType</code> cannot be altered in any way, including through the use of methods inherited from the <a href="core.html#ID-1950641247"><code>Node</code></a> interface, such as <code>insertNode</code> or <code>removeNode</code>.<br> </dd> <dt><code class="attribute-name"><a id="ID-87CD092" name="ID-87CD092">documentElement</a></code> of type <a href="core.html#ID-745549614"><code>Element</code></a>, readonly</dt> <dd>This is a <a href="glossary.html#dt-convenience"><em>convenience</em></a> attribute that allows direct access to the child node that is the root element of the document. For HTML documents, this is the element with the tagName "HTML".<br> </dd> <dt><code class="attribute-name"><a id="ID-1B793EBA" name="ID-1B793EBA">implementation</a></code> of type <a href="core.html#ID-102161490"><code>DOMImplementation</code></a>, readonly</dt> <dd>The <a href="core.html#ID-102161490"><code>DOMImplementation</code></a> object that handles this document. A DOM application may use objects from multiple implementations.<br> </dd> </dl> </dd> <dt><b>Methods</b></dt> <dd> <dl> <dt><code class="method-name"><a id="ID-1084891198" name="ID-1084891198">createAttribute</a></code></dt> <dd> <div class="method">Creates an <a href="core.html#ID-637646024"><code>Attr</code></a> of the given name. Note that the <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> instance can then be set on an <a href="core.html#ID-745549614"><code>Element</code></a> using the <code>setAttributeNode</code> method.<br> To create an attribute with a qualified name and namespace URI, use the <code>createAttributeNS</code> method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">name</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The name of the attribute.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-637646024"><code>Attr</code></a></p> </td> <td> <p>A new <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> object with the <code>nodeName</code> attribute set to <code>name</code>, and <code>localName</code>, <code>prefix</code>, and <code>namespaceURI</code> set to <code>null</code>. The value of the attribute is the empty string.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-DocCrAttrNS" name="ID-DocCrAttrNS">createAttributeNS</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Creates an attribute of the given qualified name and namespace URI. HTML-only DOM implementations do not need to implement this method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">namespaceURI</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-namespaceURI"><em>namespace URI</em></a> of the attribute to create.<br> </dd> <dt><code class="parameter-name">qualifiedName</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-qualifiedname"><em>qualified name</em></a> of the attribute to instantiate.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-637646024"><code>Attr</code></a></p> </td> <td> <p>A new <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> object with the following attributes:</p> <table border="1" summary="Layout table: the first cell the name property, the second cell contains his initial value"> <tbody><tr> <th>Attribute</th> <th>Value</th> </tr> <tr> <td valign="top" rowspan="1" colspan="1"><a href="core.html#ID-F68D095"><code>Node.nodeName</code></a></td> <td valign="top" rowspan="1" colspan="1">qualifiedName</td> </tr> <tr> <td valign="top" rowspan="1" colspan="1"><a href="core.html#ID-NodeNSname"><code>Node.namespaceURI</code></a></td> <td valign="top" rowspan="1" colspan="1"> <code>namespaceURI</code></td> </tr> <tr> <td valign="top" rowspan="1" colspan="1"><a href="core.html#ID-NodeNSPrefix"><code>Node.prefix</code></a></td> <td valign="top" rowspan="1" colspan="1">prefix, extracted from <code>qualifiedName</code>, or <code>null</code> if there is no prefix</td> </tr> <tr> <td valign="top" rowspan="1" colspan="1"><a href="core.html#ID-NodeNSLocalN"><code>Node.localName</code></a></td> <td valign="top" rowspan="1" colspan="1"><a class="noxref" href="glossary.html#dt-localname"><em>local name</em></a>, extracted from <code>qualifiedName</code></td> </tr> <tr> <td valign="top" rowspan="1" colspan="1"><a href="core.html#ID-1112119403"><code>Attr.name</code></a></td> <td valign="top" rowspan="1" colspan="1"> <code>qualifiedName</code></td> </tr> <tr> <td valign="top" rowspan="1" colspan="1"><a href="core.html#ID-F68D080"><code>Node.nodeValue</code></a></td> <td valign="top" rowspan="1" colspan="1">the empty string</td> </tr> </tbody></table> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.</p> <p>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>, if the <code>qualifiedName</code> has a prefix that is "xml" and the <code>namespaceURI</code> is different from "<a href="http://www.w3.org/XML/1998/namespace">http://www.w3.org/XML/1998/namespace</a>", or if the <code>qualifiedName</code> is "xmlns" and the <code>namespaceURI</code> is different from "<a href="http://www.w3.org/2000/xmlns/">http://www.w3.org/2000/xmlns/</a>".</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-D26C0AF8" name="ID-D26C0AF8">createCDATASection</a></code></dt> <dd> <div class="method">Creates a <a href="core.html#ID-667469212"><code>CDATASection</code></a> node whose value is the specified string. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">data</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The data for the <a href="core.html#ID-667469212"><code>CDATASection</code></a> contents.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-667469212"><code>CDATASection</code></a></p> </td> <td> <p>The new <a class="noxref" href="core.html#ID-667469212"><code>CDATASection</code></a> object.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-1334481328" name="ID-1334481328">createComment</a></code></dt> <dd> <div class="method">Creates a <a href="core.html#ID-1728279322"><code>Comment</code></a> node given the specified string. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">data</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The data for the node.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1728279322"><code>Comment</code></a></p> </td> <td> <p>The new <a class="noxref" href="core.html#ID-1728279322"><code>Comment</code></a> object.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-35CB04B5" name="ID-35CB04B5">createDocumentFragment</a></code></dt> <dd> <div class="method">Creates an empty <a href="core.html#ID-B63ED1A3"><code>DocumentFragment</code></a> object. <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-B63ED1A3"><code>DocumentFragment</code></a></p> </td> <td> <p>A new <a class="noxref" href="core.html#ID-B63ED1A3"><code>DocumentFragment</code></a>.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Parameters</b></div> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-2141741547" name="ID-2141741547">createElement</a></code></dt> <dd> <div class="method">Creates an element of the type specified. Note that the instance returned implements the <a href="core.html#ID-745549614"><code>Element</code></a> interface, so attributes can be specified directly on the returned object.<br> In addition, if there are known attributes with default values, <a href="core.html#ID-637646024"><code>Attr</code></a> nodes representing them are automatically created and attached to the element.<br> To create an element with a qualified name and namespace URI, use the <code>createElementNS</code> method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">tagName</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The name of the element type to instantiate. For XML, this is case-sensitive. For HTML, the <code>tagName</code> parameter may be provided in any case, but it must be mapped to the canonical uppercase form by the DOM implementation.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-745549614"><code>Element</code></a></p> </td> <td> <p>A new <a class="noxref" href="core.html#ID-745549614"><code>Element</code></a> object with the <code>nodeName</code> attribute set to <code>tagName</code>, and <code>localName</code>, <code>prefix</code>, and <code>namespaceURI</code> set to <code>null</code>.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-DocCrElNS" name="ID-DocCrElNS">createElementNS</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Creates an element of the given qualified name and namespace URI. HTML-only DOM implementations do not need to implement this method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">namespaceURI</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-namespaceURI"><em>namespace URI</em></a> of the element to create.<br> </dd> <dt><code class="parameter-name">qualifiedName</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-qualifiedname"><em>qualified name</em></a> of the element type to instantiate.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-745549614"><code>Element</code></a></p> </td> <td> <p>A new <a class="noxref" href="core.html#ID-745549614"><code>Element</code></a> object with the following attributes:</p> <table border="1" summary="Layout table: the first cell the name property, the second cell contains his initial value"> <tbody><tr> <th>Attribute</th> <th>Value</th> </tr> <tr> <td valign="top" rowspan="1" colspan="1"><a href="core.html#ID-F68D095"><code>Node.nodeName</code></a></td> <td valign="top" rowspan="1" colspan="1"> <code>qualifiedName</code></td> </tr> <tr> <td valign="top" rowspan="1" colspan="1"><a href="core.html#ID-NodeNSname"><code>Node.namespaceURI</code></a></td> <td valign="top" rowspan="1" colspan="1"> <code>namespaceURI</code></td> </tr> <tr> <td valign="top" rowspan="1" colspan="1"><a href="core.html#ID-NodeNSPrefix"><code>Node.prefix</code></a></td> <td valign="top" rowspan="1" colspan="1">prefix, extracted from <code>qualifiedName</code>, or <code>null</code> if there is no prefix</td> </tr> <tr> <td valign="top" rowspan="1" colspan="1"><a href="core.html#ID-NodeNSLocalN"><code>Node.localName</code></a></td> <td valign="top" rowspan="1" colspan="1"><a class="noxref" href="glossary.html#dt-localname"><em>local name</em></a>, extracted from <code>qualifiedName</code></td> </tr> <tr> <td valign="top" rowspan="1" colspan="1"><a href="core.html#ID-104682815"><code>Element.tagName</code></a></td> <td valign="top" rowspan="1" colspan="1"> <code>qualifiedName</code></td> </tr> </tbody></table> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.</p> <p>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 if the <code>qualifiedName</code> has a prefix that is "xml" and the <code>namespaceURI</code> is different from "<a href="http://www.w3.org/XML/1998/namespace">http://www.w3.org/XML/1998/namespace</a>" [<a class="noxref" href="references.html#Namespaces">Namespaces</a>].</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-392B75AE" name="ID-392B75AE">createEntityReference</a></code></dt> <dd> <div class="method">Creates an <a href="core.html#ID-11C98490"><code>EntityReference</code></a> object. In addition, if the referenced entity is known, the child list of the <a class="noxref" href="core.html#ID-11C98490"><code>EntityReference</code></a> node is made the same as that of the corresponding <a href="core.html#ID-527DCFF2"><code>Entity</code></a> node. <p><b>Note:</b> If any descendant of the <a href="core.html#ID-527DCFF2"><code>Entity</code></a> node has an unbound <a href="glossary.html#dt-namespaceprefix"><em>namespace prefix</em></a>, the corresponding descendant of the created <a href="core.html#ID-11C98490"><code>EntityReference</code></a> node is also unbound; (its <code>namespaceURI</code> is <code>null</code>). The DOM Level 2 does not support any mechanism to resolve namespace prefixes.</p> <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">name</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The name of the entity to reference.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-11C98490"><code>EntityReference</code></a></p> </td> <td> <p>The new <a class="noxref" href="core.html#ID-11C98490"><code>EntityReference</code></a> object.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.</p> <p>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-135944439" name="ID-135944439">createProcessingInstruction</a></code></dt> <dd> <div class="method">Creates a <a href="core.html#ID-1004215813"><code>ProcessingInstruction</code></a> node given the specified name and data strings. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">target</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The target part of the processing instruction.<br> </dd> <dt><code class="parameter-name">data</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The data for the node.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1004215813"><code>ProcessingInstruction</code></a></p> </td> <td> <p>The new <a class="noxref" href="core.html#ID-1004215813"><code>ProcessingInstruction</code></a> object.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INVALID_CHARACTER_ERR: Raised if the specified target contains an illegal character.</p> <p>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-1975348127" name="ID-1975348127">createTextNode</a></code></dt> <dd> <div class="method">Creates a <a href="core.html#ID-1312295772"><code>Text</code></a> node given the specified string. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">data</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The data for the node.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1312295772"><code>Text</code></a></p> </td> <td> <p>The new <a class="noxref" href="core.html#ID-1312295772"><code>Text</code></a> object.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-getElBId" name="ID-getElBId">getElementById</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Returns the <a href="core.html#ID-745549614"><code>Element</code></a> whose <code>ID</code> is given by <code>elementId</code>. If no such element exists, returns <code>null</code>. Behavior is not defined if more than one element has this <code>ID</code>. <p><b>Note:</b> The DOM implementation must have information that says which attributes are of type ID. Attributes with the name "ID" are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return <code>null</code>.</p> <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">elementId</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The unique <code>id</code> value for an element.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-745549614"><code>Element</code></a></p> </td> <td> <p>The matching element.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-A6C9094" name="ID-A6C9094">getElementsByTagName</a></code></dt> <dd> <div class="method">Returns a <a href="core.html#ID-536297177"><code>NodeList</code></a> of all the <a href="core.html#ID-745549614"><code>Elements</code></a> with a given tag name in the order in which they are encountered in a preorder traversal of the <code>Document</code> tree. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">tagname</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The name of the tag to match on. The special value "*" matches all tags.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-536297177"><code>NodeList</code></a></p> </td> <td> <p>A new <a class="noxref" href="core.html#ID-536297177"><code>NodeList</code></a> object containing all the matched <a href="core.html#ID-745549614"><code>Elements</code></a>.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-getElBTNNS" name="ID-getElBTNNS">getElementsByTagNameNS</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Returns a <a href="core.html#ID-536297177"><code>NodeList</code></a> of all the <a href="core.html#ID-745549614"><code>Elements</code></a> with a given <a href="glossary.html#dt-localname"><em>local name</em></a> and namespace URI in the order in which they are encountered in a preorder traversal of the <code>Document</code> tree. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">namespaceURI</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-namespaceURI"><em>namespace URI</em></a> of the elements to match on. The special value "*" matches all namespaces.<br> </dd> <dt><code class="parameter-name">localName</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-localname"><em>local name</em></a> of the elements to match on. The special value "*" matches all local names.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-536297177"><code>NodeList</code></a></p> </td> <td> <p>A new <a class="noxref" href="core.html#ID-536297177"><code>NodeList</code></a> object containing all the matched <a href="core.html#ID-745549614"><code>Elements</code></a>.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="Core-Document-importNode" name="Core-Document-importNode">importNode</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Imports a node from another document to this document. The returned node has no parent; (<code>parentNode</code> is <code>null</code>). The source node is not altered or removed from the original document; this method creates a new copy of the source node.<br> For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node's <code>nodeName</code> and <code>nodeType</code>, plus the attributes related to namespaces (<code>prefix</code>, <code>localName</code>, and <code>namespaceURI</code>). As in the <code>cloneNode</code> operation on a <a href="core.html#ID-1950641247"><code>Node</code></a>, the source node is not altered.<br> Additional information is copied as appropriate to the <code>nodeType</code>, attempting to mirror the behavior expected if a fragment of XML or HTML source was copied from one document to another, recognizing that the two documents may have different DTDs in the XML case. The following list describes the specifics for each type of node. <dl> <dt><b>ATTRIBUTE_NODE</b></dt> <dd>The <code>ownerElement</code> attribute is set to <code>null</code> and the <code>specified</code> flag is set to <code>true</code> on the generated <a href="core.html#ID-637646024"><code>Attr</code></a>. The <a href="glossary.html#dt-descendant"><em>descendants</em></a> of the source <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> are recursively imported and the resulting nodes reassembled to form the corresponding subtree.<br> Note that the <code>deep</code> parameter has no effect on <a href="core.html#ID-637646024"><code>Attr</code></a> nodes; they always carry their children with them when imported.</dd> <dt><b>DOCUMENT_FRAGMENT_NODE</b></dt> <dd>If the <code>deep</code> option was set to <code>true</code>, the <a href="glossary.html#dt-descendant"><em>descendants</em></a> of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Otherwise, this simply generates an empty <a href="core.html#ID-B63ED1A3"><code>DocumentFragment</code></a>.</dd> <dt><b>DOCUMENT_NODE</b></dt> <dd><code>Document</code> nodes cannot be imported.</dd> <dt><b>DOCUMENT_TYPE_NODE</b></dt> <dd><a href="core.html#ID-412266927"><code>DocumentType</code></a> nodes cannot be imported.</dd> <dt><b>ELEMENT_NODE</b></dt> <dd><em>Specified</em> attribute nodes of the source element are imported, and the generated <a href="core.html#ID-637646024"><code>Attr</code></a> nodes are attached to the generated <a href="core.html#ID-745549614"><code>Element</code></a>. Default attributes are <em>not</em> copied, though if the document being imported into defines default attributes for this element name, those are assigned. If the <code>importNode</code> <code>deep</code> parameter was set to <code>true</code>, the <a href="glossary.html#dt-descendant"><em>descendants</em></a> of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree.</dd> <dt><b>ENTITY_NODE</b></dt> <dd><a href="core.html#ID-527DCFF2"><code>Entity</code></a> nodes can be imported, however in the current release of the DOM the <a href="core.html#ID-412266927"><code>DocumentType</code></a> is readonly. Ability to add these imported nodes to a <a class="noxref" href="core.html#ID-412266927"><code>DocumentType</code></a> will be considered for addition to a future release of the DOM.<br> On import, the <code>publicId</code>, <code>systemId</code>, and <code>notationName</code> attributes are copied. If a <code>deep</code> import is requested, the <a href="glossary.html#dt-descendant"><em>descendants</em></a> of the the source <a href="core.html#ID-527DCFF2"><code>Entity</code></a> are recursively imported and the resulting nodes reassembled to form the corresponding subtree.</dd> <dt><b>ENTITY_REFERENCE_NODE</b></dt> <dd>Only the <a href="core.html#ID-11C98490"><code>EntityReference</code></a> itself is copied, even if a <code>deep</code> import is requested, since the source and destination documents might have defined the entity differently. If the document being imported into provides a definition for this entity name, its value is assigned.</dd> <dt><b>NOTATION_NODE</b></dt> <dd><a href="core.html#ID-5431D1B9"><code>Notation</code></a> nodes can be imported, however in the current release of the DOM the <a href="core.html#ID-412266927"><code>DocumentType</code></a> is readonly. Ability to add these imported nodes to a <a class="noxref" href="core.html#ID-412266927"><code>DocumentType</code></a> will be considered for addition to a future release of the DOM.<br> On import, the <code>publicId</code> and <code>systemId</code> attributes are copied.<br> Note that the <code>deep</code> parameter has no effect on <a href="core.html#ID-5431D1B9"><code>Notation</code></a> nodes since they never have any children.</dd> <dt><b>PROCESSING_INSTRUCTION_NODE</b></dt> <dd>The imported node copies its <code>target</code> and <code>data</code> values from those of the source node.</dd> <dt><b>TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE</b></dt> <dd>These three types of nodes inheriting from <a href="core.html#ID-FF21A306"><code>CharacterData</code></a> copy their <code>data</code> and <code>length</code> attributes from those of the source node.</dd> </dl> <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">importedNode</code> of type <a href="core.html#ID-1950641247"><code>Node</code></a></dt> <dd>The node to import.<br> </dd> <dt><code class="parameter-name">deep</code> of type <code>boolean</code></dt> <dd>If <code>true</code>, recursively import the subtree under the specified node; if <code>false</code>, import only the node itself, as explained above. This has no effect on <a href="core.html#ID-637646024"><code>Attr</code></a>, <a href="core.html#ID-11C98490"><code>EntityReference</code></a>, and <a href="core.html#ID-5431D1B9"><code>Notation</code></a> nodes.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1950641247"><code>Node</code></a></p> </td> <td> <p>The imported node that belongs to this <code>Document</code>.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>NOT_SUPPORTED_ERR: Raised if the type of node being imported is not supported.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> </dl> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-1950641247" name="ID-1950641247">Node</a></i></b></dt> <dd> <p>The <code>Node</code> interface is the primary datatype for the entire Document Object Model. It represents a single node in the document tree. While all objects implementing the <code>Node</code> interface expose methods for dealing with children, not all objects implementing the <code>Node</code> interface may have children. For example, <a href="core.html#ID-1312295772"><code>Text</code></a> nodes may not have children, and adding children to such nodes results in a <a href="core.html#ID-17189187"><code>DOMException</code></a> being raised.</p> <p>The attributes <code>nodeName</code>, <code>nodeValue</code> and <code>attributes</code> are included as a mechanism to get at node information without casting down to the specific derived interface. In cases where there is no obvious mapping of these attributes for a specific <code>nodeType</code> (e.g., <code>nodeValue</code> for an <a href="core.html#ID-745549614"><code>Element</code></a> or <code>attributes</code> for a <a href="core.html#ID-1728279322"><code>Comment</code></a>), this returns <code>null</code>. Note that the specialized interfaces may contain additional and more convenient mechanisms to get and set the relevant information.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface Node { // NodeType const unsigned short ELEMENT_NODE = 1; const unsigned short ATTRIBUTE_NODE = 2; const unsigned short TEXT_NODE = 3; const unsigned short CDATA_SECTION_NODE = 4; const unsigned short ENTITY_REFERENCE_NODE = 5; const unsigned short ENTITY_NODE = 6; const unsigned short PROCESSING_INSTRUCTION_NODE = 7; const unsigned short COMMENT_NODE = 8; const unsigned short DOCUMENT_NODE = 9; const unsigned short DOCUMENT_TYPE_NODE = 10; const unsigned short DOCUMENT_FRAGMENT_NODE = 11; const unsigned short NOTATION_NODE = 12; readonly attribute DOMString nodeName; attribute DOMString nodeValue; // raises(DOMException) on setting // raises(DOMException) on retrieval readonly attribute unsigned short nodeType; readonly attribute Node parentNode; readonly attribute NodeList childNodes; readonly attribute Node firstChild; readonly attribute Node lastChild; readonly attribute Node previousSibling; readonly attribute Node nextSibling; readonly attribute NamedNodeMap attributes; // Modified in DOM Level 2: readonly attribute Document ownerDocument; Node insertBefore(in Node newChild, in Node refChild) raises(DOMException); Node replaceChild(in Node newChild, in Node oldChild) raises(DOMException); Node removeChild(in Node oldChild) raises(DOMException); Node appendChild(in Node newChild) raises(DOMException); boolean hasChildNodes(); Node cloneNode(in boolean deep); // Modified in DOM Level 2: void normalize(); // Introduced in DOM Level 2: boolean isSupported(in DOMString feature, in DOMString version); // Introduced in DOM Level 2: readonly attribute DOMString namespaceURI; // Introduced in DOM Level 2: attribute DOMString prefix; // raises(DOMException) on setting // Introduced in DOM Level 2: readonly attribute DOMString localName; // Introduced in DOM Level 2: boolean hasAttributes(); }; </pre> </div> <br> </dd> <dt><b>Definition group <i><a id="ID-1841493061" name="ID-1841493061">NodeType</a></i></b></dt> <dd> <p>An integer indicating which type of node this is.</p> <p><b>Note:</b> Numeric codes up to 200 are reserved to W3C for possible future use.</p> <dl> <dt><b>Defined Constants</b></dt> <dd> <dl> <dt><code class="constant-name">ATTRIBUTE_NODE</code></dt> <dd>The node is an <a href="core.html#ID-637646024"><code>Attr</code></a>.</dd> <dt><code class="constant-name">CDATA_SECTION_NODE</code></dt> <dd>The node is a <a href="core.html#ID-667469212"><code>CDATASection</code></a>.</dd> <dt><code class="constant-name">COMMENT_NODE</code></dt> <dd>The node is a <a href="core.html#ID-1728279322"><code>Comment</code></a>.</dd> <dt><code class="constant-name">DOCUMENT_FRAGMENT_NODE</code></dt> <dd>The node is a <a href="core.html#ID-B63ED1A3"><code>DocumentFragment</code></a>.</dd> <dt><code class="constant-name">DOCUMENT_NODE</code></dt> <dd>The node is a <a href="core.html#i-Document"><code>Document</code></a>.</dd> <dt><code class="constant-name">DOCUMENT_TYPE_NODE</code></dt> <dd>The node is a <a href="core.html#ID-412266927"><code>DocumentType</code></a>.</dd> <dt><code class="constant-name">ELEMENT_NODE</code></dt> <dd>The node is an <a href="core.html#ID-745549614"><code>Element</code></a>.</dd> <dt><code class="constant-name">ENTITY_NODE</code></dt> <dd>The node is an <a href="core.html#ID-527DCFF2"><code>Entity</code></a>.</dd> <dt><code class="constant-name">ENTITY_REFERENCE_NODE</code></dt> <dd>The node is an <a href="core.html#ID-11C98490"><code>EntityReference</code></a>.</dd> <dt><code class="constant-name">NOTATION_NODE</code></dt> <dd>The node is a <a href="core.html#ID-5431D1B9"><code>Notation</code></a>.</dd> <dt><code class="constant-name">PROCESSING_INSTRUCTION_NODE</code></dt> <dd>The node is a <a href="core.html#ID-1004215813"><code>ProcessingInstruction</code></a>.</dd> <dt><code class="constant-name">TEXT_NODE</code></dt> <dd>The node is a <a href="core.html#ID-1312295772"><code>Text</code></a> node.</dd> </dl> </dd> </dl> </dd> <dd> <p>The values of <code>nodeName</code>, <code>nodeValue</code>, and <code>attributes</code> vary according to the node type as follows:</p> <table border="1" summary="Layout table: the first cell contains the name of the interface, the second contains the value of the nodeName attribute for this interface, the third contains the value of the nodeValue attribute for this interface and the fourth contains the value of the attributes attribute for this interface"> <tbody><tr> <th>Interface</th> <th>nodeName</th> <th>nodeValue</th> <th>attributes</th> </tr> <tr> <td valign="top" rowspan="1" colspan="1">Attr</td> <td valign="top" rowspan="1" colspan="1">name of attribute</td> <td valign="top" rowspan="1" colspan="1">value of attribute</td> <td valign="top" rowspan="1" colspan="1">null</td> </tr> <tr> <td valign="top" rowspan="1" colspan="1">CDATASection</td> <td valign="top" rowspan="1" colspan="1">#cdata-section</td> <td valign="top" rowspan="1" colspan="1">content of the CDATA Section</td> <td valign="top" rowspan="1" colspan="1">null</td> </tr> <tr> <td valign="top" rowspan="1" colspan="1">Comment</td> <td valign="top" rowspan="1" colspan="1">#comment</td> <td valign="top" rowspan="1" colspan="1">content of the comment</td> <td valign="top" rowspan="1" colspan="1">null</td> </tr> <tr> <td valign="top" rowspan="1" colspan="1">Document</td> <td valign="top" rowspan="1" colspan="1">#document</td> <td valign="top" rowspan="1" colspan="1">null</td> <td valign="top" rowspan="1" colspan="1">null</td> </tr> <tr> <td valign="top" rowspan="1" colspan="1">DocumentFragment</td> <td valign="top" rowspan="1" colspan="1">#document-fragment</td> <td valign="top" rowspan="1" colspan="1">null</td> <td valign="top" rowspan="1" colspan="1">null</td> </tr> <tr> <td valign="top" rowspan="1" colspan="1">DocumentType</td> <td valign="top" rowspan="1" colspan="1">document type name</td> <td valign="top" rowspan="1" colspan="1">null</td> <td valign="top" rowspan="1" colspan="1">null</td> </tr> <tr> <td valign="top" rowspan="1" colspan="1">Element</td> <td valign="top" rowspan="1" colspan="1">tag name</td> <td valign="top" rowspan="1" colspan="1">null</td> <td valign="top" rowspan="1" colspan="1">NamedNodeMap</td> </tr> <tr> <td valign="top" rowspan="1" colspan="1">Entity</td> <td valign="top" rowspan="1" colspan="1">entity name</td> <td valign="top" rowspan="1" colspan="1">null</td> <td valign="top" rowspan="1" colspan="1">null</td> </tr> <tr> <td valign="top" rowspan="1" colspan="1">EntityReference</td> <td valign="top" rowspan="1" colspan="1">name of entity referenced</td> <td valign="top" rowspan="1" colspan="1">null</td> <td valign="top" rowspan="1" colspan="1">null</td> </tr> <tr> <td valign="top" rowspan="1" colspan="1">Notation</td> <td valign="top" rowspan="1" colspan="1">notation name</td> <td valign="top" rowspan="1" colspan="1">null</td> <td valign="top" rowspan="1" colspan="1">null</td> </tr> <tr> <td valign="top" rowspan="1" colspan="1">ProcessingInstruction</td> <td valign="top" rowspan="1" colspan="1">target</td> <td valign="top" rowspan="1" colspan="1">entire content excluding the target</td> <td valign="top" rowspan="1" colspan="1">null</td> </tr> <tr> <td valign="top" rowspan="1" colspan="1">Text</td> <td valign="top" rowspan="1" colspan="1">#text</td> <td valign="top" rowspan="1" colspan="1">content of the text node</td> <td valign="top" rowspan="1" colspan="1">null</td> </tr> </tbody></table> </dd> <dt><b>Attributes</b></dt> <dd> <dl> <dt><code class="attribute-name"><a id="ID-84CF096" name="ID-84CF096">attributes</a></code> of type <a href="core.html#ID-1780488922"><code>NamedNodeMap</code></a>, readonly</dt> <dd>A <a href="core.html#ID-1780488922"><code>NamedNodeMap</code></a> containing the attributes of this node (if it is an <a href="core.html#ID-745549614"><code>Element</code></a>) or <code>null</code> otherwise.<br> </dd> <dt><code class="attribute-name"><a id="ID-1451460987" name="ID-1451460987">childNodes</a></code> of type <a href="core.html#ID-536297177"><code>NodeList</code></a>, readonly</dt> <dd>A <a href="core.html#ID-536297177"><code>NodeList</code></a> that contains all children of this node. If there are no children, this is a <a class="noxref" href="core.html#ID-536297177"><code>NodeList</code></a> containing no nodes.<br> </dd> <dt><code class="attribute-name"><a id="ID-169727388" name="ID-169727388">firstChild</a></code> of type <a href="core.html#ID-1950641247"><code>Node</code></a>, readonly</dt> <dd>The first child of this node. If there is no such node, this returns <code>null</code>.<br> </dd> <dt><code class="attribute-name"><a id="ID-61AD09FB" name="ID-61AD09FB">lastChild</a></code> of type <a href="core.html#ID-1950641247"><code>Node</code></a>, readonly</dt> <dd>The last child of this node. If there is no such node, this returns <code>null</code>.<br> </dd> <dt><code class="attribute-name"><a id="ID-NodeNSLocalN" name="ID-NodeNSLocalN">localName</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly, introduced in <b class="version">DOM Level 2</b></dt> <dd>Returns the local part of the <a href="glossary.html#dt-qualifiedname"><em>qualified name</em></a> of this node.<br> For nodes of any type other than <code>ELEMENT_NODE</code> and <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 method, such as <code>createElement</code> from the <a href="core.html#i-Document"><code>Document</code></a> interface, this is always <code>null</code>.<br> </dd> <dt><code class="attribute-name"><a id="ID-NodeNSname" name="ID-NodeNSname">namespaceURI</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly, introduced in <b class="version">DOM Level 2</b></dt> <dd>The <a href="glossary.html#dt-namespaceURI"><em>namespace URI</em></a> of this node, or <code>null</code> if it is unspecified.<br> This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time.<br> For nodes of any type other than <code>ELEMENT_NODE</code> and <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 method, such as <code>createElement</code> from the <a href="core.html#i-Document"><code>Document</code></a> interface, this is always <code>null</code>. <p><b>Note:</b> Per the <em>Namespaces in XML</em> Specification [<a class="noxref" href="references.html#Namespaces">Namespaces</a>] an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it simply has no namespace.</p> </dd> <dt><code class="attribute-name"><a id="ID-6AC54C2F" name="ID-6AC54C2F">nextSibling</a></code> of type <a href="core.html#ID-1950641247"><code>Node</code></a>, readonly</dt> <dd>The node immediately following this node. If there is no such node, this returns <code>null</code>.<br> </dd> <dt><code class="attribute-name"><a id="ID-F68D095" name="ID-F68D095">nodeName</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly</dt> <dd>The name of this node, depending on its type; see the table above.<br> </dd> <dt><code class="attribute-name"><a id="ID-111237558" name="ID-111237558">nodeType</a></code> of type <code>unsigned short</code>, readonly</dt> <dd>A code representing the type of the underlying object, as defined above.<br> </dd> <dt><code class="attribute-name"><a id="ID-F68D080" name="ID-F68D080">nodeValue</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The value of this node, depending on its type; see the table above. When it is defined to be <code>null</code>, setting it has no effect.<br> <div class="exceptions"><b>Exceptions on setting</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> <div class="exceptions"><b>Exceptions on retrieval</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a <a href="core.html#DOMString"><code>DOMString</code></a> variable on the implementation platform.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </dd> <dt><code class="attribute-name"><a id="node-ownerDoc" name="node-ownerDoc">ownerDocument</a></code> of type <a href="core.html#i-Document"><code>Document</code></a>, readonly, modified in <b class="version">DOM Level 2</b></dt> <dd>The <a href="core.html#i-Document"><code>Document</code></a> object associated with this node. This is also the <a class="noxref" href="core.html#i-Document"><code>Document</code></a> object used to create new nodes. When this node is a <a class="noxref" href="core.html#i-Document"><code>Document</code></a> or a <a href="core.html#ID-412266927"><code>DocumentType</code></a> which is not used with any <a class="noxref" href="core.html#i-Document"><code>Document</code></a> yet, this is <code>null</code>.<br> </dd> <dt><code class="attribute-name"><a id="ID-1060184317" name="ID-1060184317">parentNode</a></code> of type <a href="core.html#ID-1950641247"><code>Node</code></a>, readonly</dt> <dd>The <a href="glossary.html#dt-parent"><em>parent</em></a> of this node. All nodes, except <a href="core.html#ID-637646024"><code>Attr</code></a>, <a href="core.html#i-Document"><code>Document</code></a>, <a href="core.html#ID-B63ED1A3"><code>DocumentFragment</code></a>, <a href="core.html#ID-527DCFF2"><code>Entity</code></a>, and <a href="core.html#ID-5431D1B9"><code>Notation</code></a> may have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is <code>null</code>.<br> </dd> <dt><code class="attribute-name"><a id="ID-NodeNSPrefix" name="ID-NodeNSPrefix">prefix</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, introduced in <b class="version">DOM Level 2</b></dt> <dd>The <a href="glossary.html#dt-namespaceprefix"><em>namespace prefix</em></a> of this node, or <code>null</code> if it is unspecified.<br> Note that setting this attribute, when permitted, changes the <code>nodeName</code> attribute, which holds the <a href="glossary.html#dt-qualifiedname"><em>qualified name</em></a>, as well as the <code>tagName</code> and <code>name</code> attributes of the <a href="core.html#ID-745549614"><code>Element</code></a> and <a href="core.html#ID-637646024"><code>Attr</code></a> interfaces, when applicable.<br> Note also that changing the prefix of an attribute that is known to have a default value, does not make a new attribute with the default value and the original prefix appear, since the <code>namespaceURI</code> and <code>localName</code> do not change.<br> For nodes of any type other than <code>ELEMENT_NODE</code> and <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 method, such as <code>createElement</code> from the <a href="core.html#i-Document"><code>Document</code></a> interface, this is always <code>null</code>.<br> <div class="exceptions"><b>Exceptions on setting</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal character.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> <p>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is malformed, if the <code>namespaceURI</code> of this node is <code>null</code>, if the specified prefix is "xml" and the <code>namespaceURI</code> of this node is different from "<a href="http://www.w3.org/XML/1998/namespace">http://www.w3.org/XML/1998/namespace</a>", if this node is an attribute and the specified prefix is "xmlns" and the <code>namespaceURI</code> of this node is different from "<a href="http://www.w3.org/2000/xmlns/">http://www.w3.org/2000/xmlns/</a>", or if this node is an attribute and the <code>qualifiedName</code> of this node is "xmlns" [<a class="noxref" href="references.html#Namespaces">Namespaces</a>].</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </dd> <dt><code class="attribute-name"><a id="ID-640FB3C8" name="ID-640FB3C8">previousSibling</a></code> of type <a href="core.html#ID-1950641247"><code>Node</code></a>, readonly</dt> <dd>The node immediately preceding this node. If there is no such node, this returns <code>null</code>.<br> </dd> </dl> </dd> <dt><b>Methods</b></dt> <dd> <dl> <dt><code class="method-name"><a id="ID-184E7107" name="ID-184E7107">appendChild</a></code></dt> <dd> <div class="method">Adds the node <code>newChild</code> to the end of the list of children of this node. If the <code>newChild</code> is already in the tree, it is first removed. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">newChild</code> of type <a href="core.html#ID-1950641247"><code>Node</code></a></dt> <dd>The node to add.<br> If it is a <a href="core.html#ID-B63ED1A3"><code>DocumentFragment</code></a> object, the entire contents of the document fragment are moved into the child list of this node<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1950641247"><code>Node</code></a></p> </td> <td> <p>The node added.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the <code>newChild</code> node, or if the node to append is one of this node's <a href="glossary.html#dt-ancestor"><em>ancestors</em></a>.</p> <p>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created from a different document than the one that created this node.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-3A0ED0A4" name="ID-3A0ED0A4">cloneNode</a></code></dt> <dd> <div class="method">Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent; (<code>parentNode</code> is <code>null</code>.).<br> Cloning an <a href="core.html#ID-745549614"><code>Element</code></a> copies all attributes and their values, including those generated by the XML processor to represent defaulted attributes, but this method does not copy any text it contains unless it is a deep clone, since the text is contained in a child <a href="core.html#ID-1312295772"><code>Text</code></a> node. Cloning an <code>Attribute</code> directly, as opposed to be cloned as part of an <a class="noxref" href="core.html#ID-745549614"><code>Element</code></a> cloning operation, returns a specified attribute (<code>specified</code> is <code>true</code>). Cloning any other type of node simply returns a copy of this node.<br> Note that cloning an immutable subtree results in a mutable copy, but the children of an <a href="core.html#ID-11C98490"><code>EntityReference</code></a> clone are <a href="glossary.html#dt-readonly-node"><em>readonly</em></a>. In addition, clones of unspecified <a href="core.html#ID-637646024"><code>Attr</code></a> nodes are specified. And, cloning <a href="core.html#i-Document"><code>Document</code></a>, <a href="core.html#ID-412266927"><code>DocumentType</code></a>, <a href="core.html#ID-527DCFF2"><code>Entity</code></a>, and <a href="core.html#ID-5431D1B9"><code>Notation</code></a> nodes is implementation dependent. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">deep</code> of type <code>boolean</code></dt> <dd>If <code>true</code>, recursively clone the subtree under the specified node; if <code>false</code>, clone only the node itself (and its attributes, if it is an <a href="core.html#ID-745549614"><code>Element</code></a>).<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1950641247"><code>Node</code></a></p> </td> <td> <p>The duplicate node.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-NodeHasAttrs" name="ID-NodeHasAttrs">hasAttributes</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Returns whether this node (if it is an element) has any attributes. <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><code>boolean</code></p> </td> <td> <p><code>true</code> if this node has any attributes, <code>false</code> otherwise.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Parameters</b></div> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-810594187" name="ID-810594187">hasChildNodes</a></code></dt> <dd> <div class="method">Returns whether this node has any children. <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><code>boolean</code></p> </td> <td> <p><code>true</code> if this node has any children, <code>false</code> otherwise.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Parameters</b></div> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-952280727" name="ID-952280727">insertBefore</a></code></dt> <dd> <div class="method">Inserts the node <code>newChild</code> before the existing child node <code>refChild</code>. If <code>refChild</code> is <code>null</code>, insert <code>newChild</code> at the end of the list of children.<br> If <code>newChild</code> is a <a href="core.html#ID-B63ED1A3"><code>DocumentFragment</code></a> object, all of its children are inserted, in the same order, before <code>refChild</code>. If the <code>newChild</code> is already in the tree, it is first removed. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">newChild</code> of type <a href="core.html#ID-1950641247"><code>Node</code></a></dt> <dd>The node to insert.<br> </dd> <dt><code class="parameter-name">refChild</code> of type <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a></dt> <dd>The reference node, i.e., the node before which the new node must be inserted.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1950641247"><code>Node</code></a></p> </td> <td> <p>The node being inserted.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the <code>newChild</code> node, or if the node to insert is one of this node's <a href="glossary.html#dt-ancestor"><em>ancestors</em></a>.</p> <p>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created from a different document than the one that created this node.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the parent of the node being inserted is readonly.</p> <p>NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child of this node.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="Level-2-Core-Node-supports" name="Level-2-Core-Node-supports">isSupported</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Tests whether the DOM implementation implements a specific feature and that feature is supported by this node. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">feature</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The name of the feature to test. This is the same name which can be passed to the method <code>hasFeature</code> on <a href="core.html#ID-102161490"><code>DOMImplementation</code></a>.<br> </dd> <dt><code class="parameter-name">version</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>This is the version number of the feature to test. In Level 2, version 1, this is the string "2.0". If the version is not specified, supporting any version of the feature will cause the method to return <code>true</code>.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><code>boolean</code></p> </td> <td> <p>Returns <code>true</code> if the specified feature is supported on this node, <code>false</code> otherwise.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-normalize" name="ID-normalize">normalize</a></code> modified in <b class="version">DOM Level 2</b></dt> <dd> <div class="method">Puts all <a href="core.html#ID-1312295772"><code>Text</code></a> nodes in the full depth of the sub-tree underneath this <code>Node</code>, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates <a class="noxref" href="core.html#ID-1312295772"><code>Text</code></a> nodes, i.e., there are neither adjacent <a class="noxref" href="core.html#ID-1312295772"><code>Text</code></a> nodes nor empty <a class="noxref" href="core.html#ID-1312295772"><code>Text</code></a> nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer [<a class="noxref" href="references.html#XPointer">XPointer</a>] lookups) that depend on a particular document tree structure are to be used. <p><b>Note:</b> In cases where the document contains <a href="core.html#ID-667469212"><code>CDATASections</code></a>, the normalize operation alone may not be sufficient, since XPointers do not differentiate between <a href="core.html#ID-1312295772"><code>Text</code></a> nodes and <a href="core.html#ID-667469212"><code>CDATASection</code></a> nodes.</p> <div><b>No Parameters</b></div> <div><b>No Return Value</b></div> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-1734834066" name="ID-1734834066">removeChild</a></code></dt> <dd> <div class="method">Removes the child node indicated by <code>oldChild</code> from the list of children, and returns it. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">oldChild</code> of type <a href="core.html#ID-1950641247"><code>Node</code></a></dt> <dd>The node being removed.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1950641247"><code>Node</code></a></p> </td> <td> <p>The node removed.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> <p>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of this node.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-785887307" name="ID-785887307">replaceChild</a></code></dt> <dd> <div class="method">Replaces the child node <code>oldChild</code> with <code>newChild</code> in the list of children, and returns the <code>oldChild</code> node.<br> If <code>newChild</code> is a <a href="core.html#ID-B63ED1A3"><code>DocumentFragment</code></a> object, <code>oldChild</code> is replaced by all of the <a class="noxref" href="core.html#ID-B63ED1A3"><code>DocumentFragment</code></a> children, which are inserted in the same order. If the <code>newChild</code> is already in the tree, it is first removed. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">newChild</code> of type <a href="core.html#ID-1950641247"><code>Node</code></a></dt> <dd>The new node to put in the child list.<br> </dd> <dt><code class="parameter-name">oldChild</code> of type <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a></dt> <dd>The node being replaced in the list.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1950641247"><code>Node</code></a></p> </td> <td> <p>The node replaced.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the <code>newChild</code> node, or if the node to put in is one of this node's <a href="glossary.html#dt-ancestor"><em>ancestors</em></a>.</p> <p>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created from a different document than the one that created this node.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of the new node is readonly.</p> <p>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of this node.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> </dl> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-536297177" name="ID-536297177">NodeList</a></i></b></dt> <dd> <p>The <code>NodeList</code> interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. <code>NodeList</code> objects in the DOM are <a href="core.html#td-live"><em>live</em></a>.</p> <p>The items in the <code>NodeList</code> are accessible via an integral index, starting from 0.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface NodeList { Node item(in unsigned long index); readonly attribute unsigned long length; }; </pre> </div> <br> </dd> <dt><b>Attributes</b></dt> <dd> <dl> <dt><code class="attribute-name"><a id="ID-203510337" name="ID-203510337">length</a></code> of type <code>unsigned long</code>, readonly</dt> <dd>The number of nodes in the list. The range of valid child node indices is 0 to <code>length-1</code> inclusive.<br> </dd> </dl> </dd> <dt><b>Methods</b></dt> <dd> <dl> <dt><code class="method-name"><a id="ID-844377136" name="ID-844377136">item</a></code></dt> <dd> <div class="method">Returns the <code>index</code>th item in the collection. If <code>index</code> is greater than or equal to the number of nodes in the list, this returns <code>null</code>. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">index</code> of type <code>unsigned long</code></dt> <dd>Index into the collection.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1950641247"><code>Node</code></a></p> </td> <td> <p>The node at the <code>index</code>th position in the <code>NodeList</code>, or <code>null</code> if that is not a valid index.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> </dl> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-1780488922" name="ID-1780488922">NamedNodeMap</a></i></b></dt> <dd> <p>Objects implementing the <code>NamedNodeMap</code> interface are used to represent collections of nodes that can be accessed by name. Note that <code>NamedNodeMap</code> does not inherit from <a href="core.html#ID-536297177"><code>NodeList</code></a>; <code>NamedNodeMaps</code> are not maintained in any particular order. Objects contained in an object implementing <code>NamedNodeMap</code> may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a <code>NamedNodeMap</code>, and does not imply that the DOM specifies an order to these Nodes.</p> <p><code>NamedNodeMap</code> objects in the DOM are <a href="core.html#td-live"><em>live</em></a>.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface NamedNodeMap { Node getNamedItem(in DOMString name); Node setNamedItem(in Node arg) raises(DOMException); Node removeNamedItem(in DOMString name) raises(DOMException); Node item(in unsigned long index); readonly attribute unsigned long length; // Introduced in DOM Level 2: Node getNamedItemNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: Node setNamedItemNS(in Node arg) raises(DOMException); // Introduced in DOM Level 2: Node removeNamedItemNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException); }; </pre> </div> <br> </dd> <dt><b>Attributes</b></dt> <dd> <dl> <dt><code class="attribute-name"><a id="ID-6D0FB19E" name="ID-6D0FB19E">length</a></code> of type <code>unsigned long</code>, readonly</dt> <dd>The number of nodes in this map. The range of valid child node indices is <code>0</code> to <code>length-1</code> inclusive.<br> </dd> </dl> </dd> <dt><b>Methods</b></dt> <dd> <dl> <dt><code class="method-name"><a id="ID-1074577549" name="ID-1074577549">getNamedItem</a></code></dt> <dd> <div class="method">Retrieves a node specified by name. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">name</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <code>nodeName</code> of a node to retrieve.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1950641247"><code>Node</code></a></p> </td> <td> <p>A <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a> (of any type) with the specified <code>nodeName</code>, or <code>null</code> if it does not identify any node in this map.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-getNamedItemNS" name="ID-getNamedItemNS">getNamedItemNS</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Retrieves a node specified by local name and namespace URI. HTML-only DOM implementations do not need to implement this method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">namespaceURI</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-namespaceURI"><em>namespace URI</em></a> of the node to retrieve.<br> </dd> <dt><code class="parameter-name">localName</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-localname"><em>local name</em></a> of the node to retrieve.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1950641247"><code>Node</code></a></p> </td> <td> <p>A <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a> (of any type) with the specified local name and namespace URI, or <code>null</code> if they do not identify any node in this map.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-349467F9" name="ID-349467F9">item</a></code></dt> <dd> <div class="method">Returns the <code>index</code>th item in the map. If <code>index</code> is greater than or equal to the number of nodes in this map, this returns <code>null</code>. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">index</code> of type <code>unsigned long</code></dt> <dd>Index into this map.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1950641247"><code>Node</code></a></p> </td> <td> <p>The node at the <code>index</code>th position in the map, or <code>null</code> if that is not a valid index.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-D58B193" name="ID-D58B193">removeNamedItem</a></code></dt> <dd> <div class="method">Removes a node specified by name. When this map contains the attributes attached to an element, 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. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">name</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <code>nodeName</code> of the node to remove.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1950641247"><code>Node</code></a></p> </td> <td> <p>The node removed from this map if a node with such a name exists.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in this map.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-removeNamedItemNS" name="ID-removeNamedItemNS">removeNamedItemNS</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Removes a node specified by local name and namespace URI. A removed attribute may be known to have a default value when this map contains the attributes attached to an element, as returned by the attributes attribute of the <a href="core.html#ID-1950641247"><code>Node</code></a> interface. If so, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.<br> HTML-only DOM implementations do not need to implement this method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">namespaceURI</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-namespaceURI"><em>namespace URI</em></a> of the node to remove.<br> </dd> <dt><code class="parameter-name">localName</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-localname"><em>local name</em></a> of the node to remove.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1950641247"><code>Node</code></a></p> </td> <td> <p>The node removed from this map if a node with such a local name and namespace URI exists.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>NOT_FOUND_ERR: Raised if there is no node with the specified <code>namespaceURI</code> and <code>localName</code> in this map.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-1025163788" name="ID-1025163788">setNamedItem</a></code></dt> <dd> <div class="method">Adds a node using its <code>nodeName</code> attribute. If a node with that name is already present in this map, it is replaced by the new one.<br> As the <code>nodeName</code> attribute is used to derive the name which the node must be stored under, multiple nodes of certain types (those that have a "special" string value) cannot be stored as the names would clash. This is seen as preferable to allowing nodes to be aliased. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">arg</code> of type <a href="core.html#ID-1950641247"><code>Node</code></a></dt> <dd>A node to store in this map. The node will later be accessible using the value of its <code>nodeName</code> attribute.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1950641247"><code>Node</code></a></p> </td> <td> <p>If the new <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a> replaces an existing node the replaced <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a> is returned, otherwise <code>null</code> is returned.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a different document than the one that created this map.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.</p> <p>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an <a href="core.html#ID-637646024"><code>Attr</code></a> that is already an attribute of another <a href="core.html#ID-745549614"><code>Element</code></a> object. The DOM user must explicitly clone <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> nodes to re-use them in other elements.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-setNamedItemNS" name="ID-setNamedItemNS">setNamedItemNS</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Adds a node using its <code>namespaceURI</code> and <code>localName</code>. If a node with that namespace URI and that local name is already present in this map, it is replaced by the new one.<br> HTML-only DOM implementations do not need to implement this method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">arg</code> of type <a href="core.html#ID-1950641247"><code>Node</code></a></dt> <dd>A node to store in this map. The node will later be accessible using the value of its <code>namespaceURI</code> and <code>localName</code> attributes.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1950641247"><code>Node</code></a></p> </td> <td> <p>If the new <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a> replaces an existing node the replaced <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a> is returned, otherwise <code>null</code> is returned.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a different document than the one that created this map.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.</p> <p>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an <a href="core.html#ID-637646024"><code>Attr</code></a> that is already an attribute of another <a href="core.html#ID-745549614"><code>Element</code></a> object. The DOM user must explicitly clone <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> nodes to re-use them in other elements.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> </dl> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-FF21A306" name="ID-FF21A306">CharacterData</a></i></b></dt> <dd> <p>The <code>CharacterData</code> interface extends Node with a set of attributes and methods for accessing character data in the DOM. For clarity this set is defined here rather than on each object that uses these attributes and methods. No DOM objects correspond directly to <code>CharacterData</code>, though <a href="core.html#ID-1312295772"><code>Text</code></a> and others do inherit the interface from it. All <code>offsets</code> in this interface start from <code>0</code>.</p> <p>As explained in the <a href="core.html#DOMString"><code>DOMString</code></a> interface, text strings in the DOM are represented in UTF-16, i.e. as a sequence of 16-bit units. In the following, the term <a href="glossary.html#dt-16-bit-unit"><em>16-bit units</em></a> is used whenever necessary to indicate that indexing on CharacterData is done in 16-bit units.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface CharacterData : Node { attribute DOMString data; // raises(DOMException) on setting // raises(DOMException) on retrieval readonly attribute unsigned long length; DOMString substringData(in unsigned long offset, in unsigned long count) raises(DOMException); void appendData(in DOMString arg) raises(DOMException); void insertData(in unsigned long offset, in DOMString arg) raises(DOMException); void deleteData(in unsigned long offset, in unsigned long count) raises(DOMException); void replaceData(in unsigned long offset, in unsigned long count, in DOMString arg) raises(DOMException); }; </pre> </div> <br> </dd> <dt><b>Attributes</b></dt> <dd> <dl> <dt><code class="attribute-name"><a id="ID-72AB8359" name="ID-72AB8359">data</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The character data of the node that implements this interface. The DOM implementation may not put arbitrary limits on the amount of data that may be stored in a <code>CharacterData</code> node. However, implementation limits may mean that the entirety of a node's data may not fit into a single <a href="core.html#DOMString"><code>DOMString</code></a>. In such cases, the user may call <code>substringData</code> to retrieve the data in appropriately sized pieces.<br> <div class="exceptions"><b>Exceptions on setting</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> <div class="exceptions"><b>Exceptions on retrieval</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a <a href="core.html#DOMString"><code>DOMString</code></a> variable on the implementation platform.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </dd> <dt><code class="attribute-name"><a id="ID-7D61178C" name="ID-7D61178C">length</a></code> of type <code>unsigned long</code>, readonly</dt> <dd>The number of <a href="glossary.html#dt-16-bit-unit"><em>16-bit units</em></a> that are available through <code>data</code> and the <code>substringData</code> method below. This may have the value zero, i.e., <code>CharacterData</code> nodes may be empty.<br> </dd> </dl> </dd> <dt><b>Methods</b></dt> <dd> <dl> <dt><code class="method-name"><a id="ID-32791A2F" name="ID-32791A2F">appendData</a></code></dt> <dd> <div class="method">Append the string to the end of the character data of the node. Upon success, <code>data</code> provides access to the concatenation of <code>data</code> and the <a href="core.html#DOMString"><code>DOMString</code></a> specified. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">arg</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a> to append.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> <div><b>No Return Value</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-7C603781" name="ID-7C603781">deleteData</a></code></dt> <dd> <div class="method">Remove a range of <a href="glossary.html#dt-16-bit-unit"><em>16-bit units</em></a> from the node. Upon success, <code>data</code> and <code>length</code> reflect the change. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">offset</code> of type <code>unsigned long</code></dt> <dd>The offset from which to start removing.<br> </dd> <dt><code class="parameter-name">count</code> of type <code>unsigned long</code></dt> <dd>The number of 16-bit units to delete. If the sum of <code>offset</code> and <code>count</code> exceeds <code>length</code> then all 16-bit units from <code>offset</code> to the end of the data are deleted.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is negative or greater than the number of 16-bit units in <code>data</code>, or if the specified <code>count</code> is negative.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> <div><b>No Return Value</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-3EDB695F" name="ID-3EDB695F">insertData</a></code></dt> <dd> <div class="method">Insert a string at the specified <a href="glossary.html#dt-16-bit-unit"><em>16-bit unit</em></a> offset. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">offset</code> of type <code>unsigned long</code></dt> <dd>The character offset at which to insert.<br> </dd> <dt><code class="parameter-name">arg</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a> to insert.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is negative or greater than the number of 16-bit units in <code>data</code>.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> <div><b>No Return Value</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-E5CBA7FB" name="ID-E5CBA7FB">replaceData</a></code></dt> <dd> <div class="method">Replace the characters starting at the specified <a href="glossary.html#dt-16-bit-unit"><em>16-bit unit</em></a> offset with the specified string. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">offset</code> of type <code>unsigned long</code></dt> <dd>The offset from which to start replacing.<br> </dd> <dt><code class="parameter-name">count</code> of type <code>unsigned long</code></dt> <dd>The number of 16-bit units to replace. If the sum of <code>offset</code> and <code>count</code> exceeds <code>length</code>, then all 16-bit units to the end of the data are replaced; (i.e., the effect is the same as a <code>remove</code> method call with the same range, followed by an <code>append</code> method invocation).<br> </dd> <dt><code class="parameter-name">arg</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a> with which the range must be replaced.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is negative or greater than the number of 16-bit units in <code>data</code>, or if the specified <code>count</code> is negative.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> <div><b>No Return Value</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-6531BCCF" name="ID-6531BCCF">substringData</a></code></dt> <dd> <div class="method">Extracts a range of data from the node. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">offset</code> of type <code>unsigned long</code></dt> <dd>Start offset of substring to extract.<br> </dd> <dt><code class="parameter-name">count</code> of type <code>unsigned long</code></dt> <dd>The number of 16-bit units to extract.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#DOMString"><code>DOMString</code></a></p> </td> <td> <p>The specified substring. If the sum of <code>offset</code> and <code>count</code> exceeds the <code>length</code>, then all 16-bit units to the end of the data are returned.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is negative or greater than the number of 16-bit units in <code>data</code>, or if the specified <code>count</code> is negative.</p> <p>DOMSTRING_SIZE_ERR: Raised if the specified range of text does not fit into a <a href="core.html#DOMString"><code>DOMString</code></a>.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> </dl> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-637646024" name="ID-637646024">Attr</a></i></b></dt> <dd> <p>The <code>Attr</code> interface represents an attribute in an <a href="core.html#ID-745549614"><code>Element</code></a> object. Typically the allowable values for the attribute are defined in a document type definition.</p> <p><code>Attr</code> objects inherit the <a href="core.html#ID-1950641247"><code>Node</code></a> interface, but since they are not actually child nodes of the element they describe, the DOM does not consider them part of the document tree. Thus, the <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a> attributes <code>parentNode</code>, <code>previousSibling</code>, and <code>nextSibling</code> have a <code>null</code> value for <code>Attr</code> objects. The DOM takes the view that attributes are properties of elements rather than having a separate identity from the elements they are associated with; this should make it more efficient to implement such features as default attributes associated with all elements of a given type. Furthermore, <code>Attr</code> nodes may not be immediate children of a <a href="core.html#ID-B63ED1A3"><code>DocumentFragment</code></a>. However, they can be associated with <a href="core.html#ID-745549614"><code>Element</code></a> nodes contained within a <a class="noxref" href="core.html#ID-B63ED1A3"><code>DocumentFragment</code></a>. In short, users and implementors of the DOM need to be aware that <code>Attr</code> nodes have some things in common with other objects inheriting the <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a> interface, but they also are quite distinct.</p> <p>The attribute's effective value is determined as follows: if this attribute has been explicitly assigned any value, that value is the attribute's effective value; otherwise, if there is a declaration for this attribute, and that declaration includes a default value, then that default value is the attribute's effective value; otherwise, the attribute does not exist on this element in the structure model until it has been explicitly added. Note that the <code>nodeValue</code> attribute on the <code>Attr</code> instance can also be used to retrieve the string version of the attribute's value(s).</p> <p>In XML, where the value of an attribute can contain entity references, the child nodes of the <code>Attr</code> node may be either <a href="core.html#ID-1312295772"><code>Text</code></a> or <a href="core.html#ID-11C98490"><code>EntityReference</code></a> nodes (when these are in use; see the description of <a class="noxref" href="core.html#ID-11C98490"><code>EntityReference</code></a> for discussion). Because the DOM Core is not aware of attribute types, it treats all attribute values as simple strings, even if the DTD or schema declares them as having <a href="glossary.html#dt-tokenized"><em>tokenized</em></a> types.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface Attr : Node { readonly attribute DOMString name; readonly attribute boolean specified; attribute DOMString value; // raises(DOMException) on setting // Introduced in DOM Level 2: readonly attribute Element ownerElement; }; </pre> </div> <br> </dd> <dt><b>Attributes</b></dt> <dd> <dl> <dt><code class="attribute-name"><a id="ID-1112119403" name="ID-1112119403">name</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly</dt> <dd>Returns the name of this attribute.<br> </dd> <dt><code class="attribute-name"><a id="Attr-ownerElement" name="Attr-ownerElement">ownerElement</a></code> of type <a href="core.html#ID-745549614"><code>Element</code></a>, readonly, introduced in <b class="version">DOM Level 2</b></dt> <dd>The <a href="core.html#ID-745549614"><code>Element</code></a> node this attribute is attached to or <code>null</code> if this attribute is not in use.<br> </dd> <dt><code class="attribute-name"><a id="ID-862529273" name="ID-862529273">specified</a></code> of type <code>boolean</code>, readonly</dt> <dd>If this attribute was explicitly given a value in the original document, this is <code>true</code>; otherwise, it is <code>false</code>. Note that the implementation is in charge of this attribute, not the user. If the user changes the value of the attribute (even if it ends up having the same value as the default value) then the <code>specified</code> flag is automatically flipped to <code>true</code>. To re-specify the attribute as the default value from the DTD, the user must delete the attribute. The implementation will then make a new attribute available with <code>specified</code> set to <code>false</code> and the default value (if one exists).<br> In summary: <ul> <li>If the attribute has an assigned value in the document then <code>specified</code> is <code>true</code>, and the value is the assigned value.</li> <li>If the attribute has no assigned value in the document and has a default value in the DTD, then <code>specified</code> is <code>false</code>, and the value is the default value in the DTD.</li> <li>If the attribute has no assigned value in the document and has a value of #IMPLIED in the DTD, then the attribute does not appear in the structure model of the document.</li> <li>If the <code>ownerElement</code> attribute is <code>null</code> (i.e. because it was just created or was set to <code>null</code> by the various removal and cloning operations) <code>specified</code> is <code>true</code>.</li> </ul> <br> </dd> <dt><code class="attribute-name"><a id="ID-221662474" name="ID-221662474">value</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>On retrieval, the value of the attribute is returned as a string. Character and general entity references are replaced with their values. See also the method <code>getAttribute</code> on the <a href="core.html#ID-745549614"><code>Element</code></a> interface.<br> On setting, this creates a <a href="core.html#ID-1312295772"><code>Text</code></a> node with the unparsed contents of the string. I.e. any characters that an XML processor would recognize as markup are instead treated as literal text. See also the method <code>setAttribute</code> on the <a href="core.html#ID-745549614"><code>Element</code></a> interface.<br> <div class="exceptions"><b>Exceptions on setting</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </dd> </dl> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-745549614" name="ID-745549614">Element</a></i></b></dt> <dd> <p>The <code>Element</code> interface represents an <a href="glossary.html#dt-element"><em>element</em></a> in an HTML or XML document. Elements may have attributes associated with them; since the <code>Element</code> interface inherits from <a href="core.html#ID-1950641247"><code>Node</code></a>, the generic <a class="noxref" href="core.html#ID-1950641247"><code>Node</code></a> interface attribute <code>attributes</code> may be used to retrieve the set of all attributes for an element. There are methods on the <code>Element</code> interface to retrieve either an <a href="core.html#ID-637646024"><code>Attr</code></a> object by name or an attribute value by name. In XML, where an attribute value may contain entity references, an <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> 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 <a href="glossary.html#dt-convenience"><em>convenience</em></a>.</p> <p><b>Note:</b> In DOM Level 2, the method <code>normalize</code> is inherited from the <a href="core.html#ID-1950641247"><code>Node</code></a> interface where it was moved.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface Element : Node { readonly attribute DOMString tagName; DOMString getAttribute(in DOMString name); void setAttribute(in DOMString name, in DOMString value) raises(DOMException); void removeAttribute(in DOMString name) raises(DOMException); Attr getAttributeNode(in DOMString name); Attr setAttributeNode(in Attr newAttr) raises(DOMException); Attr removeAttributeNode(in Attr oldAttr) raises(DOMException); NodeList getElementsByTagName(in DOMString name); // Introduced in DOM Level 2: DOMString getAttributeNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: void setAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName, in DOMString value) raises(DOMException); // Introduced in DOM Level 2: void removeAttributeNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException); // Introduced in DOM Level 2: Attr getAttributeNodeNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: Attr setAttributeNodeNS(in Attr newAttr) raises(DOMException); // Introduced in DOM Level 2: NodeList getElementsByTagNameNS(in DOMString namespaceURI, in DOMString localName); // Introduced in DOM Level 2: boolean hasAttribute(in DOMString name); // Introduced in DOM Level 2: boolean hasAttributeNS(in DOMString namespaceURI, in DOMString localName); }; </pre> </div> <br> </dd> <dt><b>Attributes</b></dt> <dd> <dl> <dt><code class="attribute-name"><a id="ID-104682815" name="ID-104682815">tagName</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly</dt> <dd>The name of the element. For example, in: <div class="code-block"> <pre><elementExample id="demo"> ... </elementExample> , </pre> </div> <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. The HTML DOM returns the <code>tagName</code> of an HTML element in the canonical uppercase form, regardless of the case in the source HTML document.<br> </dd> </dl> </dd> <dt><b>Methods</b></dt> <dd> <dl> <dt><code class="method-name"><a id="ID-666EE0F9" name="ID-666EE0F9">getAttribute</a></code></dt> <dd> <div class="method">Retrieves an attribute value by name. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">name</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The name of the attribute to retrieve.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#DOMString"><code>DOMString</code></a></p> </td> <td> <p>The <a href="core.html#ID-637646024"><code>Attr</code></a> value as a string, or the empty string if that attribute does not have a specified or default value.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-ElGetAttrNS" name="ID-ElGetAttrNS">getAttributeNS</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Retrieves an attribute value by local name and namespace URI. HTML-only DOM implementations do not need to implement this method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">namespaceURI</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-namespaceURI"><em>namespace URI</em></a> of the attribute to retrieve.<br> </dd> <dt><code class="parameter-name">localName</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-localname"><em>local name</em></a> of the attribute to retrieve.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#DOMString"><code>DOMString</code></a></p> </td> <td> <p>The <a href="core.html#ID-637646024"><code>Attr</code></a> value as a string, or the empty string if that attribute does not have a specified or default value.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-217A91B8" name="ID-217A91B8">getAttributeNode</a></code></dt> <dd> <div class="method">Retrieves an attribute node by name.<br> To retrieve an attribute node by qualified name and namespace URI, use the <code>getAttributeNodeNS</code> method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">name</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The name (<code>nodeName</code>) of the attribute to retrieve.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-637646024"><code>Attr</code></a></p> </td> <td> <p>The <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> node with the specified name (<code>nodeName</code>) or <code>null</code> if there is no such attribute.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-ElGetAtNodeNS" name="ID-ElGetAtNodeNS">getAttributeNodeNS</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Retrieves an <a href="core.html#ID-637646024"><code>Attr</code></a> node by local name and namespace URI. HTML-only DOM implementations do not need to implement this method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">namespaceURI</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-namespaceURI"><em>namespace URI</em></a> of the attribute to retrieve.<br> </dd> <dt><code class="parameter-name">localName</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-localname"><em>local name</em></a> of the attribute to retrieve.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-637646024"><code>Attr</code></a></p> </td> <td> <p>The <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> node with the specified attribute local name and namespace URI or <code>null</code> if there is no such attribute.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-1938918D" name="ID-1938918D">getElementsByTagName</a></code></dt> <dd> <div class="method">Returns a <a href="core.html#ID-536297177"><code>NodeList</code></a> of all <a href="glossary.html#dt-descendant"><em>descendant</em></a> <code>Elements</code> with a given tag name, in the order in which they are encountered in a preorder traversal of this <code>Element</code> tree. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">name</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The name of the tag to match on. The special value "*" matches all tags.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-536297177"><code>NodeList</code></a></p> </td> <td> <p>A list of matching <code>Element</code> nodes.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-A6C90942" name="ID-A6C90942">getElementsByTagNameNS</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Returns a <a href="core.html#ID-536297177"><code>NodeList</code></a> of all the <a href="glossary.html#dt-descendant"><em>descendant</em></a> <code>Elements</code> with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this <code>Element</code> tree.<br> HTML-only DOM implementations do not need to implement this method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">namespaceURI</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-namespaceURI"><em>namespace URI</em></a> of the elements to match on. The special value "*" matches all namespaces.<br> </dd> <dt><code class="parameter-name">localName</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-localname"><em>local name</em></a> of the elements to match on. The special value "*" matches all local names.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-536297177"><code>NodeList</code></a></p> </td> <td> <p>A new <a class="noxref" href="core.html#ID-536297177"><code>NodeList</code></a> object containing all the matched <code>Elements</code>.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-ElHasAttr" name="ID-ElHasAttr">hasAttribute</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">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. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">name</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The name of the attribute to look for.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><code>boolean</code></p> </td> <td> <p><code>true</code> if an attribute with the given name is specified on this element or has a default value, <code>false</code> otherwise.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-ElHasAttrNS" name="ID-ElHasAttrNS">hasAttributeNS</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">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. HTML-only DOM implementations do not need to implement this method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">namespaceURI</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-namespaceURI"><em>namespace URI</em></a> of the attribute to look for.<br> </dd> <dt><code class="parameter-name">localName</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-localname"><em>local name</em></a> of the attribute to look for.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><code>boolean</code></p> </td> <td> <p><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.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div><b>No Exceptions</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-6D6AC0F9" name="ID-6D6AC0F9">removeAttribute</a></code></dt> <dd> <div class="method">Removes an attribute by name. 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. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">name</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The name of the attribute to remove.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> <div><b>No Return Value</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-ElRemAtNS" name="ID-ElRemAtNS">removeAttributeNS</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">Removes an attribute by local name and namespace URI. 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.<br> HTML-only DOM implementations do not need to implement this method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">namespaceURI</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-namespaceURI"><em>namespace URI</em></a> of the attribute to remove.<br> </dd> <dt><code class="parameter-name">localName</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-localname"><em>local name</em></a> of the attribute to remove.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> <div><b>No Return Value</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-D589198" name="ID-D589198">removeAttributeNode</a></code></dt> <dd> <div class="method">Removes the specified attribute node. If the removed <a href="core.html#ID-637646024"><code>Attr</code></a> 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. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">oldAttr</code> of type <a href="core.html#ID-637646024"><code>Attr</code></a></dt> <dd>The <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> node to remove from the attribute list.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-637646024"><code>Attr</code></a></p> </td> <td> <p>The <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> node that was removed.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> <p>NOT_FOUND_ERR: Raised if <code>oldAttr</code> is not an attribute of the element.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-F68F082" name="ID-F68F082">setAttribute</a></code></dt> <dd> <div class="method">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 <a href="core.html#ID-637646024"><code>Attr</code></a> node plus any <a href="core.html#ID-1312295772"><code>Text</code></a> and <a href="core.html#ID-11C98490"><code>EntityReference</code></a> nodes, build the appropriate subtree, and use <code>setAttributeNode</code> to assign it as the value of an attribute.<br> To set an attribute with a qualified name and namespace URI, use the <code>setAttributeNS</code> method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">name</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The name of the attribute to create or alter.<br> </dd> <dt><code class="parameter-name">value</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>Value to set in string form.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> <div><b>No Return Value</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-ElSetAttrNS" name="ID-ElSetAttrNS">setAttributeNS</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">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 <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 <a href="core.html#ID-637646024"><code>Attr</code></a> node plus any <a href="core.html#ID-1312295772"><code>Text</code></a> and <a href="core.html#ID-11C98490"><code>EntityReference</code></a> nodes, build the appropriate subtree, and use <code>setAttributeNodeNS</code> or <code>setAttributeNode</code> to assign it as the value of an attribute.<br> HTML-only DOM implementations do not need to implement this method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">namespaceURI</code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-namespaceURI"><em>namespace URI</em></a> of the attribute to create or alter.<br> </dd> <dt><code class="parameter-name">qualifiedName</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The <a href="glossary.html#dt-qualifiedname"><em>qualified name</em></a> of the attribute to create or alter.<br> </dd> <dt><code class="parameter-name">value</code> of type <a class="noxref" href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The value to set in string form.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> <p>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>, if the <code>qualifiedName</code> has a prefix that is "xml" and the <code>namespaceURI</code> is different from "<a href="http://www.w3.org/XML/1998/namespace">http://www.w3.org/XML/1998/namespace</a>", or if the <code>qualifiedName</code> is "xmlns" and the <code>namespaceURI</code> is different from "<a href="http://www.w3.org/2000/xmlns/">http://www.w3.org/2000/xmlns/</a>".</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> <div><b>No Return Value</b></div> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-887236154" name="ID-887236154">setAttributeNode</a></code></dt> <dd> <div class="method">Adds a new attribute node. If an attribute with that name (<code>nodeName</code>) is already present in the element, it is replaced by the new one.<br> To add a new attribute node with a qualified name and namespace URI, use the <code>setAttributeNodeNS</code> method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">newAttr</code> of type <a href="core.html#ID-637646024"><code>Attr</code></a></dt> <dd>The <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> node to add to the attribute list.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-637646024"><code>Attr</code></a></p> </td> <td> <p>If the <code>newAttr</code> attribute replaces an existing attribute, the replaced <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> node is returned, otherwise <code>null</code> is returned.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>WRONG_DOCUMENT_ERR: Raised if <code>newAttr</code> was created from a different document than the one that created the element.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> <p>INUSE_ATTRIBUTE_ERR: Raised if <code>newAttr</code> is already an attribute of another <code>Element</code> object. The DOM user must explicitly clone <a href="core.html#ID-637646024"><code>Attr</code></a> nodes to re-use them in other elements.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> <dt><code class="method-name"><a id="ID-ElSetAtNodeNS" name="ID-ElSetAtNodeNS">setAttributeNodeNS</a></code> introduced in <b class="since">DOM Level 2</b></dt> <dd> <div class="method">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.<br> HTML-only DOM implementations do not need to implement this method. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">newAttr</code> of type <a href="core.html#ID-637646024"><code>Attr</code></a></dt> <dd>The <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> node to add to the attribute list.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-637646024"><code>Attr</code></a></p> </td> <td> <p>If the <code>newAttr</code> attribute replaces an existing attribute with the same <a href="glossary.html#dt-localname"><em>local name</em></a> and <a href="glossary.html#dt-namespaceURI"><em>namespace URI</em></a>, the replaced <a class="noxref" href="core.html#ID-637646024"><code>Attr</code></a> node is returned, otherwise <code>null</code> is returned.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>WRONG_DOCUMENT_ERR: Raised if <code>newAttr</code> was created from a different document than the one that created the element.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> <p>INUSE_ATTRIBUTE_ERR: Raised if <code>newAttr</code> is already an attribute of another <code>Element</code> object. The DOM user must explicitly clone <a href="core.html#ID-637646024"><code>Attr</code></a> nodes to re-use them in other elements.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> </dl> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-1312295772" name="ID-1312295772">Text</a></i></b></dt> <dd> <p>The <code>Text</code> interface inherits from <a href="core.html#ID-FF21A306"><code>CharacterData</code></a> and represents the textual content (termed <a href="http://www.w3.org/TR/1998/REC-xml-19980210#syntax"><em>character data</em></a> in XML) of an <a href="core.html#ID-745549614"><code>Element</code></a> or <a href="core.html#ID-637646024"><code>Attr</code></a>. If there is no markup inside an element's content, the text is contained in a single object implementing the <code>Text</code> interface that is the only child of the element. If there is markup, it is parsed into the <a href="glossary.html#dt-infoitem"><em>information items</em></a> (elements, comments, etc.) and <code>Text</code> nodes that form the list of children of the element.</p> <p>When a document is first made available via the DOM, there is only one <code>Text</code> node for each block of text. Users may create adjacent <code>Text</code> nodes that represent the contents of a given element without any intervening markup, but should be aware that there is no way to represent the separations between these nodes in XML or HTML, so they will not (in general) persist between DOM editing sessions. The <code>normalize()</code> method on <a href="core.html#ID-1950641247"><code>Node</code></a> merges any such adjacent <code>Text</code> objects into a single node for each block of text.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface Text : CharacterData { Text splitText(in unsigned long offset) raises(DOMException); }; </pre> </div> <br> </dd> <dt><b>Methods</b></dt> <dd> <dl> <dt><code class="method-name"><a id="ID-38853C1D" name="ID-38853C1D">splitText</a></code></dt> <dd> <div class="method">Breaks this node into two nodes at the specified <code>offset</code>, keeping both in the tree as <a href="glossary.html#dt-sibling"><em>siblings</em></a>. After being split, this node will contain all the content up to the <code>offset</code> point. A new node of the same type, which contains all the content at and after the <code>offset</code> point, is returned. If the original node had a parent node, the new node is inserted as the next <a href="glossary.html#dt-sibling"><em>sibling</em></a> of the original node. When the <code>offset</code> is equal to the length of this node, the new node has no data. <div class="parameters"><b>Parameters</b> <div class="paramtable"> <dl> <dt><code class="parameter-name">offset</code> of type <code>unsigned long</code></dt> <dd>The <a href="glossary.html#dt-16-bit-unit"><em>16-bit unit</em></a> offset at which to split, starting from <code>0</code>.<br> </dd> </dl> </div> </div> <!-- parameters --> <div class="return"><b>Return Value</b> <div class="returntable"> <table summary="Layout table: the first cell contains the type of the return value, the second contains a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-1312295772"><code>Text</code></a></p> </td> <td> <p>The new node, of the same type as this node.</p> </td> </tr> </tbody></table> </div> </div> <!-- return --> <div class="exceptions"><b>Exceptions</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in <code>data</code>.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </div> <!-- method --> </dd> </dl> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-1728279322" name="ID-1728279322">Comment</a></i></b></dt> <dd> <p>This interface inherits from <a href="core.html#ID-FF21A306"><code>CharacterData</code></a> and represents the content of a comment, i.e., all the characters between the starting '<code><!--</code>' and ending '<code>--></code>'. Note that this is the definition of a comment in XML, and, in practice, HTML, although some HTML tools may implement the full SGML comment structure.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface Comment : CharacterData { }; </pre> </div> <br> </dd> </dl> </dd> </dl> </div> <!-- div2 ID-BBACDC08 --> <div class="div2"><a id="ID-E067D597" name="ID-E067D597"></a> <h2 id="ID-E067D597-h2" class="div2">1.3. Extended Interfaces</h2> <p>The interfaces defined here form part of the DOM Core specification, but objects that expose these interfaces will never be encountered in a DOM implementation that deals only with HTML. As such, HTML-only DOM implementations [<a class="noxref" href="references.html#DOMHTML-inf">DOM Level 2 HTML</a>] do not need to have objects that implement these interfaces.</p> <p>The interfaces found within this section are not mandatory. A DOM application may use the <code>hasFeature(feature, version)</code> method of the <a href="core.html#ID-102161490"><code>DOMImplementation</code></a> interface with parameter values "XML" and "2.0" (respectively) to determine whether or not this module is supported by the implementation. In order to fully support this module, an implementation must also support the "Core" feature defined in <a href="core.html#ID-BBACDC08">Fundamental Interfaces</a>. Please refer to additional information about <a href="introduction.html#ID-Conformance">Conformance</a> in this specification.</p> <dl> <dt><b>Interface <i><a id="ID-667469212" name="ID-667469212">CDATASection</a></i></b></dt> <dd> <p>CDATA sections are used to escape blocks of text containing characters that would otherwise be regarded as markup. The only delimiter that is recognized in a CDATA section is the "]]>" string that ends the CDATA section. CDATA sections cannot be nested. Their primary purpose is for including material such as XML fragments, without needing to escape all the delimiters.</p> <p>The <a href="core.html#DOMString"><code>DOMString</code></a> attribute of the <a href="core.html#ID-1312295772"><code>Text</code></a> node holds the text that is contained by the CDATA section. Note that this <em>may</em> contain characters that need to be escaped outside of CDATA sections and that, depending on the character encoding ("charset") chosen for serialization, it may be impossible to write out some characters as part of a CDATA section.</p> <p>The <code>CDATASection</code> interface inherits from the <a href="core.html#ID-FF21A306"><code>CharacterData</code></a> interface through the <a href="core.html#ID-1312295772"><code>Text</code></a> interface. Adjacent <code>CDATASection</code> nodes are not merged by use of the <code>normalize</code> method of the <a href="core.html#ID-1950641247"><code>Node</code></a> interface.</p> <p><b>Note:</b> Because no markup is recognized within a <code>CDATASection</code>, character numeric references cannot be used as an escape mechanism when serializing. Therefore, action needs to be taken when serializing a <code>CDATASection</code> with a character encoding where some of the contained characters cannot be represented. Failure to do so would not produce well-formed XML.<br> One potential solution in the serialization process is to end the CDATA section before the character, output the character using a character reference or entity reference, and open a new CDATA section for any further characters in the text node. Note, however, that some code conversion libraries at the time of writing do not return an error or exception when a character is missing from the encoding, making the task of ensuring that data is not corrupted on serialization more difficult.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface CDATASection : Text { }; </pre> </div> <br> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-412266927" name="ID-412266927">DocumentType</a></i></b></dt> <dd> <p>Each <a href="core.html#i-Document"><code>Document</code></a> has a <code>doctype</code> attribute whose value is either <code>null</code> or a <code>DocumentType</code> object. The <code>DocumentType</code> interface in the DOM Core provides an interface to the list of entities that are defined for the document, and little else because the effect of namespaces and the various XML schema efforts on DTD representation are not clearly understood as of this writing.</p> <p>The DOM Level 2 doesn't support editing <code>DocumentType</code> nodes.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface DocumentType : Node { readonly attribute DOMString name; readonly attribute NamedNodeMap entities; readonly attribute NamedNodeMap notations; // Introduced in DOM Level 2: readonly attribute DOMString publicId; // Introduced in DOM Level 2: readonly attribute DOMString systemId; // Introduced in DOM Level 2: readonly attribute DOMString internalSubset; }; </pre> </div> <br> </dd> <dt><b>Attributes</b></dt> <dd> <dl> <dt><code class="attribute-name"><a id="ID-1788794630" name="ID-1788794630">entities</a></code> of type <a href="core.html#ID-1780488922"><code>NamedNodeMap</code></a>, readonly</dt> <dd>A <a href="core.html#ID-1780488922"><code>NamedNodeMap</code></a> containing the general entities, both external and internal, declared in the DTD. Parameter entities are not contained. Duplicates are discarded. For example in: <div class="code-block"> <pre><!DOCTYPE ex SYSTEM "ex.dtd" [ <!ENTITY foo "foo"> <!ENTITY bar "bar"> <!ENTITY bar "bar2"> <!ENTITY % baz "baz"> ]> <ex/> </pre> </div> the interface provides access to <code>foo</code> and the first declaration of <code>bar</code> but not the second declaration of <code>bar</code> or <code>baz</code>. Every node in this map also implements the <a href="core.html#ID-527DCFF2"><code>Entity</code></a> interface.<br> The DOM Level 2 does not support editing entities, therefore <code>entities</code> cannot be altered in any way.<br> </dd> <dt><code class="attribute-name"><a id="ID-Core-DocType-internalSubset" name="ID-Core-DocType-internalSubset">internalSubset</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly, introduced in <b class="version">DOM Level 2</b></dt> <dd>The internal subset as a string. <p><b>Note:</b> The actual content returned depends on how much information is available to the implementation. This may vary depending on various parameters, including the XML processor used to build the document.</p> </dd> <dt><code class="attribute-name"><a id="ID-1844763134" name="ID-1844763134">name</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly</dt> <dd>The name of DTD; i.e., the name immediately following the <code>DOCTYPE</code> keyword.<br> </dd> <dt><code class="attribute-name"><a id="ID-D46829EF" name="ID-D46829EF">notations</a></code> of type <a href="core.html#ID-1780488922"><code>NamedNodeMap</code></a>, readonly</dt> <dd>A <a href="core.html#ID-1780488922"><code>NamedNodeMap</code></a> containing the notations declared in the DTD. Duplicates are discarded. Every node in this map also implements the <a href="core.html#ID-5431D1B9"><code>Notation</code></a> interface.<br> The DOM Level 2 does not support editing notations, therefore <code>notations</code> cannot be altered in any way.<br> </dd> <dt><code class="attribute-name"><a id="ID-Core-DocType-publicId" name="ID-Core-DocType-publicId">publicId</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly, introduced in <b class="version">DOM Level 2</b></dt> <dd>The public identifier of the external subset.<br> </dd> <dt><code class="attribute-name"><a id="ID-Core-DocType-systemId" name="ID-Core-DocType-systemId">systemId</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly, introduced in <b class="version">DOM Level 2</b></dt> <dd>The system identifier of the external subset.<br> </dd> </dl> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-5431D1B9" name="ID-5431D1B9">Notation</a></i></b></dt> <dd> <p>This interface represents a notation declared in the DTD. A notation either declares, by name, the format of an unparsed entity (see <a href="http://www.w3.org/TR/1998/REC-xml-19980210#Notations"><em>section 4.7</em></a> of the XML 1.0 specification [<a class="noxref" href="references.html#XML">XML</a>]), or is used for formal declaration of processing instruction targets (see <a href="http://www.w3.org/TR/1998/REC-xml-19980210#sec-pi"><em>section 2.6</em></a> of the XML 1.0 specification [<a class="noxref" href="references.html#XML">XML</a>]). The <code>nodeName</code> attribute inherited from <a href="core.html#ID-1950641247"><code>Node</code></a> is set to the declared name of the notation.</p> <p>The DOM Level 1 does not support editing <code>Notation</code> nodes; they are therefore <a href="glossary.html#dt-readonly-node"><em>readonly</em></a>.</p> <p>A <code>Notation</code> node does not have any parent.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface Notation : Node { readonly attribute DOMString publicId; readonly attribute DOMString systemId; }; </pre> </div> <br> </dd> <dt><b>Attributes</b></dt> <dd> <dl> <dt><code class="attribute-name"><a id="ID-54F2B4D0" name="ID-54F2B4D0">publicId</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly</dt> <dd>The public identifier of this notation. If the public identifier was not specified, this is <code>null</code>.<br> </dd> <dt><code class="attribute-name"><a id="ID-E8AAB1D0" name="ID-E8AAB1D0">systemId</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly</dt> <dd>The system identifier of this notation. If the system identifier was not specified, this is <code>null</code>.<br> </dd> </dl> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-527DCFF2" name="ID-527DCFF2">Entity</a></i></b></dt> <dd> <p>This interface represents an entity, either parsed or unparsed, in an XML document. Note that this models the entity itself <em>not</em> the entity declaration. <code>Entity</code> declaration modeling has been left for a later Level of the DOM specification.</p> <p>The <code>nodeName</code> attribute that is inherited from <a href="core.html#ID-1950641247"><code>Node</code></a> contains the name of the entity.</p> <p>An XML processor may choose to completely expand entities before the structure model is passed to the DOM; in this case there will be no <a href="core.html#ID-11C98490"><code>EntityReference</code></a> nodes in the document tree.</p> <p>XML does not mandate that a non-validating XML processor read and process entity declarations made in the external subset or declared in external parameter entities. This means that parsed entities declared in the external subset need not be expanded by some classes of applications, and that the replacement value of the entity may not be available. When the replacement value is available, the corresponding <code>Entity</code> node's child list represents the structure of that replacement text. Otherwise, the child list is empty.</p> <p>The DOM Level 2 does not support editing <code>Entity</code> nodes; if a user wants to make changes to the contents of an <code>Entity</code>, every related <a href="core.html#ID-11C98490"><code>EntityReference</code></a> node has to be replaced in the structure model by a clone of the <code>Entity</code>'s contents, and then the desired changes must be made to each of those clones instead. <code>Entity</code> nodes and all their <a href="glossary.html#dt-descendant"><em>descendants</em></a> are <a href="glossary.html#dt-readonly-node"><em>readonly</em></a>.</p> <p>An <code>Entity</code> node does not have any parent.</p> <p><b>Note:</b> If the entity contains an unbound <a href="glossary.html#dt-namespaceprefix"><em>namespace prefix</em></a>, the <code>namespaceURI</code> of the corresponding node in the <code>Entity</code> node subtree is <code>null</code>. The same is true for <a href="core.html#ID-11C98490"><code>EntityReference</code></a> nodes that refer to this entity, when they are created using the <code>createEntityReference</code> method of the <a href="core.html#i-Document"><code>Document</code></a> interface. The DOM Level 2 does not support any mechanism to resolve namespace prefixes.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface Entity : Node { readonly attribute DOMString publicId; readonly attribute DOMString systemId; readonly attribute DOMString notationName; }; </pre> </div> <br> </dd> <dt><b>Attributes</b></dt> <dd> <dl> <dt><code class="attribute-name"><a id="ID-6ABAEB38" name="ID-6ABAEB38">notationName</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly</dt> <dd>For unparsed entities, the name of the notation for the entity. For parsed entities, this is <code>null</code>.<br> </dd> <dt><code class="attribute-name"><a id="ID-D7303025" name="ID-D7303025">publicId</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly</dt> <dd>The public identifier associated with the entity, if specified. If the public identifier was not specified, this is <code>null</code>.<br> </dd> <dt><code class="attribute-name"><a id="ID-D7C29F3E" name="ID-D7C29F3E">systemId</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly</dt> <dd>The system identifier associated with the entity, if specified. If the system identifier was not specified, this is <code>null</code>.<br> </dd> </dl> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-11C98490" name="ID-11C98490">EntityReference</a></i></b></dt> <dd> <p><code>EntityReference</code> objects may be inserted into the structure model when an entity reference is in the source document, or when the user wishes to insert an entity reference. Note that character references and references to predefined entities are considered to be expanded by the HTML or XML processor so that characters are represented by their Unicode equivalent rather than by an entity reference. Moreover, the XML processor may completely expand references to entities while building the structure model, instead of providing <code>EntityReference</code> objects. If it does provide such objects, then for a given <code>EntityReference</code> node, it may be that there is no <a href="core.html#ID-527DCFF2"><code>Entity</code></a> node representing the referenced entity. If such an <a class="noxref" href="core.html#ID-527DCFF2"><code>Entity</code></a> exists, then the subtree of the <code>EntityReference</code> node is in general a copy of the <a class="noxref" href="core.html#ID-527DCFF2"><code>Entity</code></a> node subtree. However, this may not be true when an entity contains an unbound <a href="glossary.html#dt-namespaceprefix"><em>namespace prefix</em></a>. In such a case, because the namespace prefix resolution depends on where the entity reference is, the <a href="glossary.html#dt-descendant"><em>descendants</em></a> of the <code>EntityReference</code> node may be bound to different <a href="glossary.html#dt-namespaceURI"><em>namespace URIs</em></a>.</p> <p>As for <a href="core.html#ID-527DCFF2"><code>Entity</code></a> nodes, <code>EntityReference</code> nodes and all their <a href="glossary.html#dt-descendant"><em>descendants</em></a> are <a href="glossary.html#dt-readonly-node"><em>readonly</em></a>.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface EntityReference : Node { }; </pre> </div> <br> </dd> </dl> </dd> <dt><b>Interface <i><a id="ID-1004215813" name="ID-1004215813">ProcessingInstruction</a></i></b></dt> <dd> <p>The <code>ProcessingInstruction</code> interface represents a "processing instruction", used in XML as a way to keep processor-specific information in the text of the document.</p> <dl> <dt><br> <b>IDL Definition</b></dt> <dd> <div class="idl-code"> <pre>interface ProcessingInstruction : Node { readonly attribute DOMString target; attribute DOMString data; // raises(DOMException) on setting }; </pre> </div> <br> </dd> <dt><b>Attributes</b></dt> <dd> <dl> <dt><code class="attribute-name"><a id="ID-837822393" name="ID-837822393">data</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a></dt> <dd>The content of this processing instruction. This is from the first non white space character after the target to the character immediately preceding the <code>?></code>.<br> <div class="exceptions"><b>Exceptions on setting</b> <div class="exceptiontable"> <table summary="Layout table: the first cell contains the type of the exception, the second contains the specific error code and a short description" border="0"> <tbody><tr> <td valign="top"> <p><a href="core.html#ID-17189187"><code>DOMException</code></a></p> </td> <td> <p>NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.</p> </td> </tr> </tbody></table> </div> </div> <!-- exceptions --> </dd> <dt><code class="attribute-name"><a id="ID-1478689192" name="ID-1478689192">target</a></code> of type <a href="core.html#DOMString"><code>DOMString</code></a>, readonly</dt> <dd>The target of this processing instruction. XML defines this as being the first <a href="glossary.html#dt-token"><em>token</em></a> following the markup that begins the processing instruction.<br> </dd> </dl> </dd> </dl> </dd> </dl> </div> <!-- div2 ID-E067D597 --></div> <!-- div1 Core --> <div class="navbar" align="center"> <hr title="Navigation area separator"> <a accesskey="p" href="introduction.html">previous</a> <a accesskey="n" href="changes.html">next</a> <a accesskey="c" href="Overview.html#contents">contents</a> <a accesskey="i" href="def-index.html">index</a></div> </body>
Script Preparation code:
var i, imax; var doc = document;
Tests:
getElementById
var test = doc.getElementById('ID-removeNamedItemNS').childNodes[0].innerHTML;
getElementsByTagName
var formelem = doc.getElementById('ID-removeNamedItemNS').getElementsByTagName('a')[0].innerHTML;
querySelector
var test = doc.getElementById('ID-removeNamedItemNS').querySelector('.ID-removeNamedItemNS').innerHTML;
getElementsByClassName
var test = doc.getElementById('ID-removeNamedItemNS').getElementsByClassName('ID-removeNamedItemNS')[0].innerHTML;
getElementsByName
var test = doc.getElementsByName('ID-removeNamedItemNS')[0].innerHTML;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
getElementById
getElementsByTagName
querySelector
getElementsByClassName
getElementsByName
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll do my best to answer your question. It seems like you have provided HTML code with some comments and markup instructions, as well as a list of individual test cases and latest benchmark results. However, I don't see a specific question or topic related to the content. Could you please clarify what you would like to know or discuss? Are these test cases related to a specific project or software?
Related benchmarks:
Get element by ID: jQuery vs getElementById vs querySelector
Get element by ID: jQuery vs getElementById vs querySelector
getElementById vs querySelector vs getElementsByClassName....
jQuery Id selector vs Document.getElementById vs Document.querySelector
getElementById VS querySelector (simple comparison)
Comments
Confirm delete:
Do you really want to delete benchmark?