?一个XML对象在javascript中调用的代码错误

user.xml:
None.gif <? xml version="1.0" encoding="gb2312" ?>
None.gif
< user >
None.gif    
< name > 爱飞翔 </ name >
None.gif    
< password > 123 </ name >
None.gif    
< friendNum > 4 </ friendNum >
None.gif
</ user >


ex35.htm:(主要部分)
None.gif 用户名: < INPUT  name ="username"  type ="text"  id ="username" >
None.gif
< P >
None.gif  密码: 
< INPUT  name ="password"  type ="text"  id ="password" >
None.gif
</ P >
None.gif
< P >
None.gif  
< INPUT  type ="submit"  name ="Submit"  value ="提交"  onClick ="checkUser()" >
None.gif
</ P >
None.gif
< XML  ID ="userXML"  SRC ="user.xml" ></ XML >
ExpandedBlockStart.gifContractedBlock.gif
< SCRIPT  language ="javascript" > dot.gif
InBlock.gif
function checkUser()
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif    
var userNameNode=userXML.XMLDocument.documentElement.selectNodes("name");
InBlock.gif    
var userNameR=userNameNode(0).firstChild.nodeValue;
InBlock.gif    
var userPasswordNode=userXML.XMLDocument.documentElement.selectNodes("password");
InBlock.gif    
var userPasswordR=userPasswordNode(0).firstChild.nodeValue;
InBlock.gif    
var userFriendNode=userXML.XMLDocument.documentElement.selectNodes("friendNum");
InBlock.gif    
var userFriendN=userFriendNode(0).firstChild.nodeValue;
InBlock.gif    
if(username.value==userNameR&&password.value==userPasswordR)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        alert(
"欢迎您,"+username.value+"!您的通讯录现在有"+friendNum.value+"位朋友");
InBlock.gif        location.href
="ex35.xml";
ExpandedSubBlockEnd.gif    }

InBlock.gif    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        alert(
"用户名和密码错误!");
InBlock.gif        clearName();
InBlock.gif        clearPassword();
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif
</ SCRIPT >


另外还有一个ex35.xml,用来显示结果.

上面我是书上写的,可是运行ex35.htm总是错误,说"userXML.XMLDocument.documentElement为空或不是对象".
请各位帮帮忙!

转载于:https://www.cnblogs.com/wddavid/archive/2005/07/27/200918.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值