XML DOM ownerElement Property
Attr object
Definition and Usage
The ownerElement property returns the element node to which an attribute belongs.
Syntax
attrObject.ownerElement
Example
The following code snippet uses loadXMLDoc() to load "books.xml" Load into xmlDoc, and return the element node to which the first category element belongs:
Example
xmlDoc
=
loadXMLDoc
(
"
books.xml
"
)
;
x
=
xmlDoc
.
getElementsByTagName
(
'
book
'
)
;
document
.
write
(
x
.
item
(
0
)
.
attributes
[
0
]
.
ownerElement
)
;
document
.
write
(
"
"
)
;
document
.
write
(
x
.
item
(
0
)
.
attributes
[
0
]
.
ownerElement
.
nodeName
)
;
document
.
write
(
"
"
)
;
document
.
write
(
x
.
item
(
0
)
.
attributes
[
0
]
.
ownerElement
.
nodeType
)
;
The code above will output:
[object Element]
book
1
Try it »
Attr object