METHOD:  NamedNodeMap::removeNamedItem


The removeNamedItem method removes the specified item from the collection and returns it as a Node object, or returns null if the item does not exist. If the node is an attribute with a default value, it is immediately replaced.

The following example loads the 'states.xml' file and uses the removeNamedItem method to remove the 'const' attribute of the first 'State' element. It then displays the nodeValue of the returned Node, and a statement of the current length of the NamedNodeMap.

   <State ref="FL" const="27">
   <State ref="IA" const="29">
      <capital>Des Moines</capital>

Code (JavaScript):
xml_doc = new ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;

element = xml_doc.documentElement.firstChild;
atts = element.attributes;
removed_node = atts.removeNamedItem("const");
document.write("<br>Number of remaining attributes: " + atts.length);

Number of remaining attributes: 1

Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information