XML DOM removeNamedItem()Methods


NamedNodeMap Object

Definition and Usage

The removeNamedItem() method deletes the specified node.

If the deleted attribute has a default value, then a new attribute will be immediately created, along with its namespace URI, local name, and prefix.

This method returns the deleted node.

Syntax

removeNamedItem(nodename)

Parameter Description
nodename The name of the node to remove

Example

The following code snippet usesloadXMLDoc()put "books.xmlLoad into xmlDoc, loop through the <book> elements, and delete the category attribute:

Example

xmlDoc=loadXMLDoc("books.xml"); x=xmlDoc.getElementsByTagName('book'); for(i=0;i<x.length;i++) { x.item(i).attributes.removeNamedItem("category"); }

Try it Yourself »

NamedNodeMap Objectother extensions