-- 作者:NancyYIBR
-- 发布时间:4/9/2006 8:48:00 PM
-- 求助管理员!!!
管理员: 你好! 下面是我编写的一个asp+xml的通讯录,可是运行时总是提示找不到对象。你能帮我看下是什么问题么?谢谢了:){Post=1000}{/Post} addressbook.xml <?xml version="1.0" encoding="GB2312"?> <addressbook> <person> <name>微笑的鱼</name> <sex></sex> <telephone></telephone> <address></address> <qq></qq> <email></email> <homepage></homepage> <comment>生是过客,跋涉虚无之境。</comment> </person> </addressbook> Input.htm <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>通讯录</title> <style type="text/css"> <!-- a:link { color: #000000; } a:active { color: #66CCFF; } a:hover { color: #66CCFF; } a { font-size: 14px; } --> </style> </head> <body> <form Action="PostInput.asp" Method="POST"> <table border="1" style="border-collapse: collapse" bordercolor="#66CCFF" align="center" width="460"> <tr> <td valign="middle" align="center" bgcolor="#66CCFF" colspan="2" width="460" height="85"> <font style="color:White;background-color:#66CCFF;font-family:华文行楷;font-size:X-Large;font-weight:bold;">欢迎来到“刀刀鱼”的通讯录</font> </td> </tr> <tr> <td width="460" height="26" align="left" colspan="2"></td> </tr> <tr> <td width="95" height="26" align="right" bgcolor="#e0e0e0"> <font>姓名:</font> </td> <td width="360" height="26" valign="middle" align="left" bgcolor="#e0e0e0"> <input type="text" name="name" size="20"> **</td> </tr> <tr> <td width="95" height="26" align="right"> <font>性别:</font> </td> <td width="360" height="26" valign="middle" align="left"> <input type="text" name="sex" size="20"> </td> </tr> <tr> <td width="95" height="26" align="right" bgcolor="#e0e0e0"> <font>电话:</font> </td> <td width="360" height="26" valign="middle" align="left" bgcolor="#e0e0e0"> <input type="text" name="telephone" size="20"> </td> </tr> <tr> <td width="95" height="26" align="right"> <font>地址:</font> </td> <td width="360" height="26" valign="middle" align="left"> <input type="text" name="address" size="20"> </td> </tr> <tr> <td width="95" height="26" align="right" bgcolor="#e0e0e0"> <font>QQ号码:</font> </td> <td width="360" height="26" valign="middle" align="left" bgcolor="#e0e0e0"> <input type="text" name="qq" size="20"> </td> </tr> <tr> <td width="95" height="26" align="right"> <font>E-mail:</font> </td> <td width="360" height="26" valign="middle" align="left"> <input type="text" name="email" size="30"> </td> </tr> <tr> <td width="95" height="26" align="right" bgcolor="#e0e0e0"> <font>个人主页:</font> </td> <td width="360" height="26" valign="middle" align="left" bgcolor="#e0e0e0"> <input type="text" name="homepage" size="40" value="http://"> </td> </tr> <tr> <td width="95" height="26" valign="top" align="right"> <font>个人说明:</font> </td> <td width="360" height="26" valign="top" align="left"><textarea name="comment" rows="5" cols="50"></textarea></td> </tr> <tr> <td width="460" height="26" align="left" colspan="2"> <center> <input type="Submit" name="send" value="提交信息"> <a href="show.asp">浏览通讯录</a> <input type="Reset" name="" value="清除重写"> </center> </td> </tr> </table> </form> </body> </html> PostInput.asp <% name = Request("name") if name ="" then Response.Write "姓名不能为空!" Response.End end if sex = Request("sex") telephone = Request("telephone") address = Request("address") qq = Request("qq") email = Request("email") homepage = Request("homepage") comment = Request("comment") Posttime =now() strSourceFile = Server.MapPath("addressbook.xml") Set objXML = Server.CreateObject("Microsoft.XMLDOM") objXML.load(strSourceFile) Set objRootlist = objXML.documentElement.selectSingleNode("addressbook") brstr=chr(13)&chr(10) XMLnode=brstr&"<person>"&brstr & _ "<name>"&name&"</name>"&brstr & _ "<sex>"&sex&"</sex>"&brstr & _ "<telephone>"&telephone&"</telephone>"&brstr & _ "<address>"&address&"</address>"&brstr & _ "<qq>"&qq&"</qq>"&brstr & _ "<email>"&email&"</email>"&brstr & _ "<homepage>"&homepage&"</homepage>"&brstr & _ "<comment>"&comment&"</comment>"&brstr & _ "</person>"&chr(13) set objXML2=Server.CreateObject("Microsoft.XMLDOM") objXML2.loadXML(XMLnode) set rootNewNode=objXML2.documentElement objRootlist.appendChild(rootNewNode) objXML.save(strSourceFile) set objXML=nothing set objXML2=nothing Response.Redirect("show.asp") %> show.asp <% strSourceFile = Server.MapPath("addressbook.xml") Set objXML = Server.CreateObject("Microsoft.FreeThreadedXMLDOM") objXML.load(strSourceFile) Set objRootsite = objXML.documentElement.selectSingleNode("addressbook") %> <html> <head> <title>通讯录</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <style type="text/css"> <!-- a:link { color: #000000; } a:active { color: #66CCFF; } a:hover { color: #66CCFF; } a { font-size: 14px; } --> </style> </head> <body> <table border="1" style="border-collapse: collapse" bordercolor="#66CCFF" align="center" width="460"> <tr> <td valign="middle" align="center" bgcolor="#66CCFF" colspan="2" width="460" height="85"> <font style="color:White;background-color:#66CCFF;font-family:华文行楷;font-size:X-Large;font-weight:bold;">欢迎来到“刀刀鱼”的通讯录</font> </td> </tr> <tr> <td width="460" height="26" align="left" colspan="2"></td> </tr> <% PageSize =5 AllNodesNum = objRootsite.childNodes.length-1 PageNum=AllNodesNum\PageSize+1 PageNo=request.querystring("PageNo") if PageNo="" then PageNo=PageNum end if StarNodes=PageNo*PageSize-1 EndNodes=(PageNo-1)*PageSize if EndNodes<0 then EndNodes=0 end if if StarNodes>AllNodesNum then EndNodes=EndNodes-(StarNodes-AllNodesNum) StarNodes=AllNodesNum end if if EndNodes<0 then EndNodes=0 end if while StarNodes>=EndNodes name = objRootsite.childNodes.item(1).text sex = objRootsite.childNodes.item(2).text telephone = objRootsite.childNodes.item(3).text address= objRootsite.childNodes.item(4).text qq= objRootsite.childNodes.item(5).text email = objRootsite.childNodes.item(6).text homepage = objRootsite.childNodes.item(7).text comment = objRootsite.childNodes.item(8).text text = replace(text,chr(13),"<br>") text = replace(text,chr(32)," ") %> <tr> <td width="95" height="26" align="right" bgcolor="#e0e0e0"> <font>姓名:</font> </td> <td width="360" height="26" valign="middle" align="left" bgcolor="#e0e0e0"> <%=name%> </td> </tr> <tr> <td width="95" height="26" align="right"> <font>性别:</font> </td> <td width="360" height="26" valign="middle" align="left"> <%=sex%> </td> </tr> <tr> <td width="95" height="26" align="right" bgcolor="#e0e0e0"> <font>电话:</font> </td> <td width="360" height="26" valign="middle" align="left" bgcolor="#e0e0e0"> <%=telephone%> </td> </tr> <tr> <td width="95" height="26" align="right"> <font>地址:</font> </td> <td width="360" height="26" valign="middle" align="left"> <%=address%> </td> </tr> <tr> <td width="95" height="26" align="right" bgcolor="#e0e0e0"> <font>QQ号码:</font> </td> <td width="360" height="26" valign="middle" align="left" bgcolor="#e0e0e0"> <%=qq%> </td> </tr> <tr> <td width="95" height="26" align="right"> <font>E-mail:</font> </td> <td width="360" height="26" valign="middle" align="left"> <a href="mailto:<%=email%>"><%=email%></a> </td> </tr> <tr> <td width="95" height="26" align="right" bgcolor="#e0e0e0"> <font>个人主页:</font> </td> <td width="360" height="26" valign="middle" align="left" bgcolor="#e0e0e0"> <a href="mailto:<%=homepage%>"><%=homepage%></a> </td> </tr> <tr> <td width="95" height="26" valign="top" align="right"> <font>个人说明:</font> </td> <td width="360" height="26" valign="top" align="left"> <%=comment%> </td> </tr> <tr> <td width="460" height="26" align="left" colspan="2"> <center> <a href="Input.htm">返回通讯录录入表单</a> </center> </td> </tr> <% StarNodes=StarNodes-1 wend set objXML=nothing %> <tr bgcolor="#FFFFFF" align="right"> <td colspan="2"> 共有<<%=PageNum%>>页 <% if cint(PageNo)<>PageNum then response.write "<a href='index.asp?PageNo="&(PageNo+1)&"'>上一页</a>" end if if cint(PageNo)<>1 then response.write "<a href='index.asp?PageNo="&(PageNo-1)&"'>下一页</a>" end if %> </td> </tr> </table> </body> </html>
|