XML DOM getAttributeNode() Method
Element Object
Definition and Usage
The getAttributeNode() method retrieves an attribute node from the current element by name.
Syntax
elementNode.getAttributeNode(name)
| Parameters | Description |
|---|---|
| name | Required. Specifies the attribute node to retrieve. |
Example
The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc, and from all
Example
xmlDoc
=
loadXMLDoc
(
"
books.xml
"
)
;
x
=
xmlDoc
.
getElementsByTagName
(
'
book
'
)
;
for
(
i
=
0
;
i
<
x
.
length
;
i
++
)
{
attnode
=
x
.
item
(
i
)
.
getAttributeNode
(
"
category
"
)
;
document
.
write
(
attnode
.
name
)
;
document
.
write
(
"
=
"
)
;
document
.
write
(
attnode
.
value
)
;
document
.
write
(
"
"
)
;
}
Output:
category = COOKING
category = CHILDREN
category = WEB
category = WEB
Try it »
Element Object