childNodes属性
Contains a node list containing the child nodes.
Script Syntax
Copy Code
objXMLDOMNodeList = oXMLDOMNode.childNodes;
Example
The following script example uses the childNodes property (collection) to return an IXMLDOMNodeList, and then iterates through the collection, displaying the value of each item's xml property.
JScript Copy Code
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
var root;
var oNodeList;
var Item;
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;
oNodeList = root.childNodes;
for (var i=0; i<oNodeList.length; i++) {
Item = oNodeList.item(i);
WScript.Echo(Item.xml);
}
}