XML DOM documentElement 属性

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 对象
计算机