以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XML基础 』  (http://bbs.xml.org.cn/list.asp?boardid=1)
----  通过asp添加节点出错。高手帮我看下。  (http://bbs.xml.org.cn/dispbbs.asp?boardid=1&rootid=&id=8228)


--  作者:umbrook
--  发布时间:6/9/2004 11:02:00 PM

--  通过asp添加节点出错。高手帮我看下。
<?xml version="1.0"enconding="gb2312"?>
<pages>
  <ID>
<机体名字>1</机体名字>
<号码>1</号码>
<驾驶员>1</驾驶员>
<所属>1</所属>
  <ID>
</pages>  //文件名为first.xml
====================================
asp文件
<%@LANGUAGE="JAVASCRIPT"%>
<%
  var a=Request.form("one");
  var b=Request.form("two");
  var c=Request.form("three");
  var d=Request.form("four");
  
  if(a!=""&&b!=""&&c!=""&&d!="")
{
      var obj=Server.CreateObject("MicroSoft.XMLDom");
          obj.load(Server.MapPath("first.xml"));

   var newnode=obj.createElement("ID");

   var newnodeChild1=obj.createElement("机体");
   newnodeChild1.text=Request.form("one");
   newnode.appendChild(newnodeChild1);

   var newnodeChild2=obj.createElement("号码");
   newnodeChild2.text=Request.form("two");
   newnode.appendChild(newnodeChild2);

   var newnodeChild3=obj.createElement("驾驶员");
   newnodeChild3.text=Request.form("three");
   newnode.appendChild(newnodeChild3);

   var newnodeChild4=obj.createElement("所属");
   newnodeChild4.text=Request.form("four");
   newnode.appendChild(newnodeChild4);

  错误点。对象为空 ---> var gennode=obj.selectSingleNode("pages")
    gennode.appendChild(newnode);

   obj.save(Server.MapPath("first.xml"));
   Response.redirect("index.htm");
}

else{
Response.write("不能为空");
Response.write("<a href='process.htm'>"+"返回"+"</a>");}
%>//文件名为add.asp


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
3,929.688ms