XML DOM removeAttributeNode()Methods


Element object

Definition and Usage

The removeAttributeNode() method removes the specified attribute node.

If the attribute's default value is defined in the DTD, the new attribute will appear with that default value.

This function returns the attribute node to be deleted.

Syntax

elementNode.removeAttributeNode(node)

Parameter Description
node Required. The node to be deleted.


Example

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

Example

xmlDoc=loadXMLDoc("books.xml"); x=xmlDoc.getElementsByTagName('book'); for (i=0;i<x.length;i++) { while (x[i].attributes.length>0) { attnode=x[i].attributes[0]; old_att=x[i].removeAttributeNode(attnode); document.write("Removed: " + old_att.nodeName) document.write(": " + old_att.nodeValue) document.write("<br>") } }

Try it Yourself »

Element objectother extensions