Ενότητα XML DOM ownerDocument
Ορισμός και χρήση
Η ιδιότητα ownerDocument επιστρέφει το ρίζα στοιχείου του κόμβουDocument όντα).
Γραμματική:
attrObject.ownerDocument
Παράδειγμα
Σε όλες τις παραδείξεις, θα χρησιμοποιήσουμε το αρχείο XML books.xml, και οι συνάρτησεις JavaScript loadXMLDoc().
Ο παρακάτω κώδικας επιστρέφει το ρίζα στοιχείου της πρώτης category ιδιοκτησίας στο 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
);
Η έξοδος του παραπάνω κώδικα είναι:
[όντα XMLDocument] #document 9