Name
NamedNodeMap.setNamedItem( ) — add a node to or replace a node in a NamedNodeMap
Availability
DOM Level 1 Core
Synopsis
Node setNamedItem(Node arg)
throws DOMException;Arguments
-
arg The node to be added to the NamedNodeMap.
Returns
The node that was replaced, or null if no node was
replaced.
Throws
This method may throw a DOMException with one of the following
code values:
-
HIERARCHY_REQUEST_ERR argis a node of a type that is not suitable for this NamedNodeMap (e.g., is not an Attr node).-
INUSE_ATTRIBUTE_ERR argis an Attr node that is already associated with an element.-
NO_MODIFICATION_ALLOWED_ERR The NamedNodeMap is read-only.
-
WRONG_DOCUMENT_ERR arghas a differentownerDocumentthan the document from which the NamedNodeMap was created.
Description
setNamedItem( ) adds the specified node to a
NamedNodeMap and allows it to be looked up using the value of the
node’s nodeName property. If the
NamedNodeMap already contains a node with that name, that node is
replaced and becomes the return value of the method.