Easy Tutorial
❮ Met Text Appenddata Prop Cdata Length ❯

XML DOM removeAttributeNode() Method



Definition and Usage

The removeAttributeNode() method removes the specified attribute node.

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

This function returns the attribute node to be removed.

Syntax

Parameter Description
node Required. The node to be removed.

Example

The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc and removes the "category" attribute node from all <book> elements:

Example

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName('book');

for (i=0;i&lt;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>")
  }
}

❮ Met Text Appenddata Prop Cdata Length ❯