XML DOM removeNamedItem () method
Definition and Usage
removeNamedItem () method removes a specified node.
If the removed attribute has a default value, a new property will immediately produce, along with the namespace URI, local name, prefix.
The method returns the removed node.
grammar
removeNamedItem(nodename)
参数 | 描述 |
---|---|
nodename | The name of the node to remove |
Examples
The following code fragment uses loadXMLDoc () to " the Books.xml " into xmlDoc loop through <book> element and remove the category properties:
Examples
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
for(i=0;i<x.length;i++)
{
x.item(i).attributes.removeNamedItem("category");
}
x=xmlDoc.getElementsByTagName('book');
for(i=0;i<x.length;i++)
{
x.item(i).attributes.removeNamedItem("category");
}
try it"
NamedNodeMap objects