Easy Tutorial
❮ Prop Attr Localname Prop Element Prefix ❯

XML DOM removeNamedItem() Method



Definition and Usage

The removeNamedItem() method removes the specified node.

If the removed attribute has a default value, a new attribute will immediately be generated, along with the namespace URI, local name, and prefix.

This method returns the removed node.

Syntax

Parameter Description
nodename The name of the node to remove

Example

The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc, iterates through the <book> elements, and removes 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");
}

❮ Prop Attr Localname Prop Element Prefix ❯