XML DOM lookupPrefix() Method
Node object
Definition and Usage
The lookupPrefix() method returns the prefix matching the specified namespace on a node.
Syntax
nodeObject.lookupPrefix(URI)
| Parameters | Description |
|---|---|
| URI | Required. The namespace URI. |
Example
The following code snippet uses loadXMLDoc() to load "books_ns.xml" Load into xmlDoc, and find the prefix of the namespace URI to which the first
Example
xmlDoc
=
loadXMLDoc
(
"
books_ns.xml
"
)
;
x
=
xmlDoc
.
getElementsByTagName
(
"
book
"
)
[
0
]
;
document
.
write
(
x
.
lookupPrefix
(
"
https://www.runoob.com/w3cnote/
"
)
)
;
Output:
c
Try it »
Node object