Thuộc tính documentElement của XML DOM
Định nghĩa và cách sử dụng
Thuộc tính documentElement có thể trả về nút gốc của tài liệu.
Cú pháp:
documentObject.documentElement
Mô hình
Trong tất cả các ví dụ, chúng ta sẽ sử dụng tệp XML books.xmlvà hàm JavaScript loadXMLDoc().
Mã đoạn sau có thể hiển thị vị trí XML tài liệu:
xmlDoc=loadXMLDoc("/example/xdom/books.xml");
var x=xmlDoc.documentElement
;
document.write("Nodename: " + x.nodeName + "<br />");
document.write("Nodevalue: " + x.nodeValue + "<br />");
document.write("Nodetype: " + x.nodeType);
Kết quả:
Nodename: bookstore Nodevalue: null Nodetype: 1