XML DOM removeAttributeNode() Method
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 removed attribute node.
Syntax
elementNode.removeAttributeNode(node)
| Parameters | Description |
|---|---|
| node | Required. The node to remove. |
Example
The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc, and remove the "category" attribute from all
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
(
"
"
)
}
}
Try it »
Element Object