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


Element Object Reference Element Object


Definition and Usage

The lookupPrefix() method returns the prefix matching the specified namespace URI on the current node.

Syntax

elementNode.lookupPrefix(URI)

Parameters Description
URI Required. The namespace of the prefix to look for.

Example

The following code snippet uses loadXMLDoc() to load "books_ns.xml" Load into xmlDoc, and in the first look up the prefix for a namespace URI in an element:

Example

xmlDoc

=

loadXMLDoc

(

"

books_ns.xml

"

)

; ​

x

=

xmlDoc

.

getElementsByTagName

(

"

book

"

)

[

0

]

; ​

document

.

write

(

x

.

lookupPrefix

(

"

http://www.runoob.com/w3cnote/

"

)

)

;

Output:

c

Try it »


Element Object Reference Element Object