XML DOM » Element » removeAttributeNode

Syntax:
element.removeAttributeNode(name)

This method removes the specified attribute from the element, returning the removed

If the removed attribute has a default value, it is immediately replaced by it.

Examples

Code:
XML:

<Albums>
   <Album ref="CD142" category="Folk">
      <title>Boil The Breakfast Early</title>
      <artist>The Chieftains</artist>
   </Album>
   <Album ref="CD720" category="Pop">
      <title>Come On Over</title>
      <artist>Shania Twain</artist>
   </Album>
   <Album ref="CD024" category="Country">
      <title>Red Dirt Girl</title>
      <artist>Emmylou Harris</artist>
   </Album>
</Albums>

JavaScript:

xml_doc = new ActiveXObject("Microsoft.XMLDOM");
xml_doc.async = false;
xml_doc.load("albums.xml");

elem = xml_doc.documentElement.lastChild;
attr = elem.getAttributeNode("category");
attr = elem.removeAttributeNode(attr);
atts = elem.attributes;
n_atts = atts.length;
for (i = 0; i < n_atts; i++)
   document.write(atts[i].name + "<br>");
Output:
ref
Explanation:

In this example using the 'albums.xml' file the 'category' attribute is removed from the last 'Album' element. The code then displays the names of the remaining attributes.

Language(s): JavaScript XML