XML DOM documentElement 屬性


Document 對象參考手冊 Document 對象

定義和用法

documentElement 屬性返回文檔的根節點。

語法

documentObject.documentElement


實例

下麵的代碼片段使用 loadXMLDoc() 把 "books.xml" 載入 xmlDoc 中,並顯示 XML 文檔的位置:

實例

xmlDoc=loadXMLDoc("books.xml"); x=xmlDoc.documentElement; document.write("Nodename: " + x.nodeName + "<br>"); document.write("Nodevalue: " + x.nodeValue + "<br>"); document.write("Nodetype: " + x.nodeType);

輸出:

Nodename: bookstore
Nodevalue: null
Nodetype: 1


Document 對象參考手冊 Document 對象