XML DOM ownerDocument Özelliği
Tanım ve Kullanım
ownerDocument özelliği, düğümün sahip olduğu kök elementi döndürür}}Document nesnesi)
Sözdizimi:
attrObject.ownerDocument
Örnek
Tüm örneklerde, XML dosyasını kullanacağız books.xmlve JavaScript fonksiyonları loadXMLDoc()。
Aşağıdaki kod parçası, XML belgesinde ilk category özellik düğümünün kök elementini döndürür:
xmlDoc=loadXMLDoc("/example/xdom/books.xml"); x=xmlDoc.getElementsByTagName('book'); document.write(x.item(0).attributes[0].ownerDocument
); document.write("<br />"); document.write(x.item(0).attributes[0].ownerDocument.nodeName
); document.write("<br />"); document.write(x.item(0).attributes[0].ownerDocument.nodeType
);
Yukarıdaki kodun çıktısı:
[object XMLDocument] #document 9