I'm attempting to to remove and add some nodes to some XML in classic asp.
heres the rough xml structure
and here's my messy code i'm playing with
It works as far as xmlDoc7.documentElement.removeChild remvnd
then falls over with the error "The parameter Node is not a child of this node"
All i'm trying to do with this bit of code is remove the problem nodes that match the problem Id's that are returned in the array. Any ideas ?
heres the rough xml structure
Code:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<datafragment id="12345">
<container>
<problem id="45565">
<data1>test data</data1>
<data2>test data</data2>
<data3>test data</data3>
</problem id="43434">
<problem>
<data1>lardee dar</data1>
<data2>lardee dar</data2>
<data3>lardee dar</data3>
</problem id="4523">
<problem>
<data1>noolaaa</data1>
<data2>ghhhhh</data2>
<data3>tjjjjhh</data3>
</problem id="45578">
<problem>
<data1>hhbbhuu</data1>
<data2>yygtty</data2>
<data3>ttytytt</data3>
</problem>
</container>
</datafragment>
<datafragment id=""767635>
<container>
<problem id="455465">
<data1>test data</data1>
<data2>test data</data2>
<data3>test data</data3>
</problemid="331122">
<problem>
<data1>lardee dar</data1>
<data2>lardee dar</data2>
<data3>lardee dar</data3>
</problem id="56784">
<problem>
<data1>noolaaa</data1>
<data2>ghhhhh</data2>
<data3>tjjjjhh</data3>
</problem id="456782">
<problem>
<data1>hhbbhuu</data1>
<data2>yygtty</data2>
<data3>ttytytt</data3>
</problem>
</container>
</datafragment>
</data>
and here's my messy code i'm playing with
Code:
Function testFunction()
Dim i, ProblemArray, copyOfOrigXML,objLst2, remvnd,xmlDoc,objNodes,objLst3,objNodes9,xmlDoc7
Dim ID, problemID
ProblemArray = Split(ProblemOrder,",")
copyOfOrigXML = session("XMLOrig")
set xmlDoc7 = Server.CreateObject("MSXML2.DomDocument.3.0")
xmlDoc7.async = false
xmlDoc7.loadXML(copyOfOrigXML)
'first remove all the problem elements
set xmlDoc = Server.CreateObject("MSXML2.DomDocument.3.0")
xmlDoc.async = false
xmlDoc.loadXML(copyOfOrigXML)
Set objNodes = Server.CreateObject("MSXML2.DomDocument.3.0")
Set objNodes = xmlDoc.getElementsByTagName("datafragment")
' This loops round the trusts
for each objLst2 in objNodes
ID = objLst2.getAttribute("id")
Set objNodes9 = objLst2.getElementsByTagName("problem")
' this loops round the problems
for each objLst3 in objNodes9
For i = 0 to ubound(ProblemArray)
If ProblemArray(i) = objLst3.getAttribute("id") Then
set remvnd= xmlDoc7.selectSingleNode("/data/datafragment[@id = '"&ID&"']/container/problem[@id='"&ProblemArray(i)&"']")
If Not remvnd Is Nothing Then
xmlDoc7.documentElement.removeChild remvnd
End If
End If
Next
Next
End Function
It works as far as xmlDoc7.documentElement.removeChild remvnd
then falls over with the error "The parameter Node is not a child of this node"
All i'm trying to do with this bit of code is remove the problem nodes that match the problem Id's that are returned in the array. Any ideas ?