XML DOM ownerDocument ਪ੍ਰਤੀਭਾ

ਵਿਆਖਿਆ ਅਤੇ ਵਰਤੋਂ

ownerDocument ਇਹ ਪ੍ਰਤੀਭਾ ਨੋਡ ਦੇ ਮੂਲ ਤੱਤ (ਦਸਤਾਵੇਜ਼ ਆਬਜ਼ਦਗੀ) ਨੂੰ ਵਾਪਸ ਦਿੰਦੀ ਹੈ。

ਵਿਧਾਨ

nodeObject.ownerDocument

ਉਦਾਹਰਣ

ਇਹ ਕੋਡ "books.xml" ਨੂੰ xmlDoc ਵਿੱਚ ਲੋਡ ਕਰੇਗਾ ਅਤੇ ਪਹਿਲੇ <title> ਨੋਡ ਦੇ ਮੂਲ ਤੱਤ ਨੂੰ ਵਾਪਸ ਦੇਵੇਗਾ:

var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
   if (this.readyState == 4 && this.status == 200) {
       myFunction(this);
   }
};
xhttp.open("GET", "books.xml", true);
xhttp.send();
function myFunction(xml) {
    var xmlDoc = xml.responseXML;
    var x = xmlDoc.getElementsByTagName("title")[0].ownerDocument;
    document.getElementById("demo").innerHTML =
    "Nodename: " + x.nodeName +
    " (nodetype: " + x.nodeType + ")"
}

亲自试一试