NamedNodeMap.setNamedItem() (Method)

A node is added to the collection having the specified node name. Any node already present with that name will be replaced.

Availability:

DOM level - 1
JavaScript - 1.5
JScript - 5.0
Internet Explorer - 5.0
Netscape - 6.0
Property/method value type:Node object
JavaScript syntax:-myNamedNodeMap.setNamedItem(aNode)
Argument list:aNodeThe node to be set

If a replacement happens, the old node that occupied the same position in the document and which was displaced by the new node will be returned as a result of this method call.

If you need to access that node again, you must make sure a reference to it is retained otherwise you will need to reconstruct the document from scratch to manufacture another.