标题:ASP操作XML的问题卡在了最后一步ReplceChild上
只看楼主
babyicesi
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-3-16
 问题点数:0 回复次数:1 
ASP操作XML的问题卡在了最后一步ReplceChild上
不好意思来打扰大家,问这么白痴的问题,可好长时间都被卡在这个上面,实在有点伤心

问题是这样的:
无论怎么改,一直都是在报这个错...

Technical Information (for support personnel)

Error Type:
Microsoft VBScript runtime (0x800A0005)
Invalid procedure call or argument: 'ReplaceChild'
/test1.asp, line 189


Browser Type:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)




这是XML的一个部分


//////////////////////////////////cc.XML//////////////////////////////////


<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<dic>
    <root>
        <rand>
            <ind>yi1</ind>
            <character>一</character>
            <pinyin>yī</pinyin>
            <pinyin1>yī</pinyin1>
            <pinyin2>yí</pinyin2>
            <pinyin3>yǐ</pinyin3>
            <pinyinAns>1</pinyinAns>
            <meaning>yī</meaning>
            <meaning1>one</meaning1>
            <meaning2>two</meaning2>
            <meaning3>three</meaning3>
            <meaningAns>1</meaningAns>
            <zw>one</zw>
            <zw1>一</zw1>
            <zw2>二</zw2>
            <zw3>三</zw3>
            <zwAns>1</zwAns>
            <dif>1</dif>
        </rand>



/////////////////////////源代码///////////////////////////



<style>
body {font-size:24px;}
</style>
<%

addok=request("addok")
If addok="" Or IsNull(addok) then


strSourceFile = Server.MapPath("./") & "\cc.xml"


'获取XML文件的路径这里根据你的虚拟目录不同而不同


Set objXML = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")

'以自由线程创建一个XML对像

objXML.load(strSourceFile)'把XML文件读入内存

Set objRootsite = objXML.documentElement.selectSingleNode("root")


num=objRootsite.childNodes.length-1

addop = Request.Form("site")
%>


<%

For i=0 To num


if addop = objRootsite.childNodes.item(i).childNodes.item(1).text Then
 
response.write"    "&objRootsite.childNodes.item(i).childNodes.item(2).text
d1 = objRootsite.childNodes.item(i).childNodes.item(0).text
d2 = objRootsite.childNodes.item(i).childNodes.item(1).text
d3 = objRootsite.childNodes.item(i).childNodes.item(2).text
d4 = objRootsite.childNodes.item(i).childNodes.item(3).text
d5 = objRootsite.childNodes.item(i).childNodes.item(4).text
d6 = objRootsite.childNodes.item(i).childNodes.item(5).text
d7 = objRootsite.childNodes.item(i).childNodes.item(6).text
d8 = objRootsite.childNodes.item(i).childNodes.item(7).text
d9 = objRootsite.childNodes.item(i).childNodes.item(8).text
d10 = objRootsite.childNodes.item(i).childNodes.item(9).text
d11 = objRootsite.childNodes.item(i).childNodes.item(10).text
d12 = objRootsite.childNodes.item(i).childNodes.item(11).text
d13 = objRootsite.childNodes.item(i).childNodes.item(12).text
d14 = objRootsite.childNodes.item(i).childNodes.item(13).text
d15 = objRootsite.childNodes.item(i).childNodes.item(14).text
d16 = objRootsite.childNodes.item(i).childNodes.item(15).text
d17 = objRootsite.childNodes.item(i).childNodes.item(16).text


End if


Next

%>

<form name="form" method="post" action="?addok=edit&id=<%=d1%>">
  <p>检索:<input type="text" name="dd1" size="30" value = <%=d1%>></p>
  <p>汉字:<input type="text" name="dd2" size="30" value = <%=d2%>></p>
  <p>拼音:<input type="text" name="dd3" size="30" value = <%=d3%>></p>
  <p>意思:<input type="text" name="dd4" size="30" value = <%=d13%>></p>
  <p></p>
  <p>Choose the right Pinyin</p>
  <p>选项一:<input type="text" name="dd11" size="30" value = <%=d4%>></p>
  <p>选项二:<input type="text" name="dd12" size="30" value = <%=d5%>></p>
  <p>选项三:<input type="text" name="dd13" size="30" value = <%=d6%>></p>
  <p>答案:  <input type="text" name="dd14" size="30" value = <%=d7%>></p>
  <p></p>
  <p>Choose the right Meaning</p>
  <p>选项一:<input type="text" name="dd21" size="30" value = <%=d9%>></p>
  <p>选项二:<input type="text" name="dd22" size="30" value = <%=d10%>></p>
  <p>选项三:<input type="text" name="dd23" size="30" value = <%=d11%>></p>
  <p>答案:  <input type="text" name="dd24" size="30" value = <%=d12%>></p>
  <p></p>
  <p>Choose the right Hanzi</p>
  <p>选项一:<input type="text" name="dd31" size="30" value = <%=d14%>></p>
  <p>选项二:<input type="text" name="dd32" size="30" value = <%=d15%>></p>
  <p>选项三:<input type="text" name="dd33" size="30" value = <%=d16%>></p>
  <p>答案:  <input type="text" name="dd34" size="30" value = <%=d17%>></p>

  <input type="submit" value="保存">
  </form>

<%
End if

If addok="edit" Then



strSourceFile = Server.MapPath("./") & "\cc.xml"


Set objXML = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")

objXML.load(strSourceFile)

Set objRootlist = objXML.documentElement.selectSingleNode("root")





num=objRootlist.childNodes.length-1

y1 = Request.Form("dd1")
y2 = Request.Form("dd2")
y3 = Request.Form("dd3")
y4 = Request.Form("dd4")

y11 = Request.Form("dd11")
y12 = Request.Form("dd12")
y13 = Request.Form("dd13")
y14 = Request.Form("dd14")

y21 = Request.Form("dd21")
y22 = Request.Form("dd22")
y23 = Request.Form("dd23")
y24 = Request.Form("dd24")

y31 = Request.Form("dd31")
y32 = Request.Form("dd32")
y33 = Request.Form("dd33")
y34 = Request.Form("dd34")



response.write(y1)
response.write(y2)
response.write(y3)
response.write(y4)

response.write(y11)
response.write(y12)
response.write(y13)
response.write(y14)

response.write(y21)
response.write(y22)
response.write(y23)
response.write(y24)


set rootOldNode=objRootlist.childNodes.item(id)

brstr=chr(13)&chr(10)&chr(9)
'brstr=""

XMLnode=brstr&"<ind>"&y1&"</ind>"&vbnewline & _
"<character>"&y2&"</character>"&vbnewline & _
"<pinyin>"&y3&"</pinyin>"&vbnewline & _
"<pinyin1>"&y11&"</pinyin1>"&vbnewline & _
"<pinyin2>"&y12&"</pinyin2>"&vbnewline & _
"<pinyin3>"&y13&"</pinyin3>"&vbnewline & _
"<pinyinAns>"&y14&"</pinyinAns>"&vbnewline & _
"<meaning>"&y3&"</meaning>"&vbnewline & _
"<meaning1>"&y21&"</meaning1>"&vbnewline & _
"<meaning2>"&y22&"</meaning2>"&vbnewline & _
"<meaning3>"&y23&"</meaning3>"&vbnewline & _
"<meaningAns>"&y24&"</meaningAns>"&vbnewline & _
"<zw>"&y4&"</zw>"&vbnewline & _
"<zw1>"&y31&"</zw1>"&vbnewline & _
"<zw2>"&y32&"</zw2>"&vbnewline & _
"<zw3>"&y33&"</zw3>"&vbnewline & _
"<zwAns>"&y34&"</zwAns>"&vbnewline & _
"<dif>"&Y34&"</dif>"&vbnewline&vbnewline






set objXML2=Server.CreateObject("Microsoft.XMLDOM")
'建立一个新XML对像
objXML2.loadXML(XMLnode)

'把XML版片段读入内存中
set rootNewNode=objXML2.documentElement

'获得objXML2的根节点,这就是出问题的地方
objRootlist.ReplaceChild rootNewNode,rootOldNode
'修改test.xml
objXML.save(strSourceFile)

set objXML=nothing
set objXML2=nothing
Response.Redirect("test.asp")
response.end

End if

%>
<script>
</script>
搜索更多相关主题的帖子: ASP ReplceChild XML 
2010-03-16 00:36
babyicesi
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-3-16
得分:0 
大哥大姐,帮帮忙啊,今天能给解决了么?
2010-03-16 00:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-299551-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.086839 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved