XML DOM lookupPrefix() Method

Definition and Usage

lookupPrefix() The method returns the prefix associated with the given namespace URI.

Syntax

nodeObject.lookupPrefix(namespaceURI)

Parameters

Parameters Description
namespaceURI Required. String. Specifies the namespace URI to be searched for.

Technical Details

DOM Version: Core Level 3 Node Object
ফলাফল স্ট্রিং।নির্দিষ্ট নামস্পেস URI-র সংযুক্ত প্রিফিক্স

উদাহরণ

এই কোড "books_ns.xml"-কে xmlDoc-তে লোড করবে, এবং দেওয়া নামস্পেস URI-র প্রিফিক্স অনুসন্ধান করবে:

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
   if (this.readyState == 4 && this.status == 200) {
       myFunction(this);
   }
};
xhttp.open("GET", "books_ns.xml", true);
xhttp.send();
function myFunction(xml) {
    var xmlDoc = xml.responseXML;
    var x = xmlDoc.getElementsByTagName("book")[0];
    document.getElementById("demo").innerHTML =
    x.lookupPrefix("https://www.codew3c.com/meishi/");
}

亲自试一试

浏览器支持

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 支持 支持 支持 支持

所有主流浏览器都支持 lookupPrefix() 方法。

注释:Internet Explorer 9 及更早版本不支持此方法。