Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XML DOM lookupPrefix() Method

XML DOM lookupPrefix() Method


Node Object Reference 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 element belongs:

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 Reference Node object