XML DOM lookupPrefix()Methods
Node object
Definition and Usage
The lookupPrefix() method returns the prefix that matches the specified namespace on a node.
Syntax
nodeObject.lookupPrefix(URI)
| Parameter | Description |
|---|---|
| URI | Required. Namespace URI. |
Example
The following code snippet usesloadXMLDoc()put "books_ns.xml" Load into xmlDoc, and find the prefix of the namespace URI that the first <book> element belongs to:
Example
xmlDoc=loadXMLDoc("books_ns.xml");
x=xmlDoc.getElementsByTagName("book")[0];
document.write(x.lookupPrefix("https://www.example.com/w3cnote/"));
Output:
c
Try it Yourself »
Node objectother extensions