Properti ownerDocument XML DOM
Definisi dan Penggunaan
Atribut ownerDocument mengembalikan elemen akar yang milik nodeObjek Document)
Sintaks:
attrObject.ownerDocument
Contoh
Dalam semua contoh, kita akan menggunakan berkas XML books.xml, serta fungsi JavaScript loadXMLDoc().
Kode berikut ini mengembalikan elemen akar pertama yang memiliki atribut category di dokumen XML:
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
);
Output kode di atas:
[objek XMLDocument] #document 9