请帮我改改下面的代码,怎么将nodes声明或定义一下。
<html>
<head>
<script language= "JavaScript " for= "window " event= "onload ">
var xmlDoc = new ActiveXObject( "Microsoft.XMLDOM ");
xmlDoc.async= "false ";
xmlDoc.load( "hello.xml ");
nodes = xmlDoc.documentElement.childNodes;
greeting.innerText = nodes.item(0).text;
</script>
<title> First XSLT Example </title>
</head>
<body bgcolor= "#FFFFFF ">
<span id= "greeting "> </span> <br>
</body>
</html>
------解决方案--------------------var nodes = xmlDoc.documentElement.childNodes;
------解决方案--------------------var nodes = xmlDoc.documentElement.childNodes;
JS一般不需要声明,如果是报undefined错,可能 hello.xml有问题,xmlDoc加载时就错了.