Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XML DOM removeNamedItem() Method

XML DOM removeNamedItem() Method


NamedNodeMap Object Reference NamedNodeMap object


Definition and Usage

The removeNamedItem() method removes the specified node.

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

This method returns the removed node.

Syntax

removeNamedItem(nodename)

Parameters Description
nodename The name of the node to remove

Example

The following code snippet uses loadXMLDoc() to load "books.xml" Load into xmlDoc, loop through the elements and remove 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 »


NamedNodeMap Object Reference NamedNodeMap object