documentElement属性

来源:互联网 发布:看篮球的软件 编辑:程序博客网 时间:2024/06/05 15:52

documentElement属性

Contains the root element of the document.

Script Syntax
 Copy Code
var objXMLDOMElement = oXMLDOMDocument.documentElement;
objXMLDOMDocument.documentElement = objXMLDOMElement;

 

Example
The following script example creates an IXMLDOMElement object and sets it to the root element of the document with the documentElement property. It then walks the document tree.

JScript Copy Code
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var root;
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   root = xmlDoc.documentElement;
   for (var i=0; i<root.childNodes.length; i++) {
      WScript.Echo(root.childNodes.item(i).childNodes.item(0).text);
   }
}

 

原创粉丝点击