Code:
function loadXML()
{
var bOneway = document.form.oneWay.value;
var bReturn = document.forms["form"].elements["return"].value;
var bOpenjaw = document.form.openJaw.value;
var xmlDoc = new ActiveXObject("MSXML2.DOMDocument.3.0");
xmlDoc.async="false";
{
==================================
removed unnecessary code
==================================
}
// If the XML document has been completely loaded then proceed
if (xmlDoc.readyState==4)
{
xmlDoc.loadXML(document.form_dummy.optionXML.value);
document.form_dummy.optionXML.disabled=true;
var optNo = parseInt(document.form.optionNumber.value);
var optNo_OJ = parseInt(document.form.optionNumber_OJ.value);
var iNoOfOpts = parseInt(document.form.iNoOfOpt.value);
// If the XML document has got options
if (xmlDoc.documentElement.hasChildNodes)
{
var oNode_D = xmlDoc.documentElement.selectNodes("Departing").item(0).selectNodes("PiccoOption");
var oNode_R = xmlDoc.documentElement.selectNodes("Returning").item(0).selectNodes("PiccoOption");
var iNoOfDep = parseInt(xmlDoc.documentElement.selectNodes("Departing").item(0).selectNodes("PiccoOption").length);
var iNoOfRet = parseInt(xmlDoc.documentElement.selectNodes("Returning").item(0).selectNodes("PiccoOption").length);
// Loop through all the options that have been returned from the database
for(var i=0; i<iNoOfDep; i++)
{
// if the current option is not the option that was selected
// then go ahead and delete it from the document
if (i!=optNo)
{
xmlDoc.firstChild.firstChild.selectNodes("Departing").removeChild(oNode_D.item(i));
}
}
// Loop through all the options that have been returned from the database
for(var i=0; i<iNoOfRet; i++)
{
// if the current option is not the option that was selected
// then go ahead and delete it from the document
if (i!=optNo_OJ)
{
xmlDoc.firstChild.selectNodes("Returning").removeChild(oNode_R.item(i));
}
}
}
document.form.optionXML_rev.value=(xmlDoc.xml); // Write the XML to the form field text box to be submitted through to NF2
}
}
This is my XML Document (example):
Code:
<PiccoReply>
<Departing>
<PiccoOption> <-- delete some of these nodes and their childnodes
~Other Nodes in here~
</PiccoOption>
<PiccoOption>
~Other Nodes in here~
</PiccoOption>
<PiccoOption>
~Other Nodes in here~
</PiccoOption>
<PiccoOption>
~Other Nodes in here~
</PiccoOption>
</Departing>
<Returning>
<PiccoOption> <-- delete some of these nodes and their childnodes
~Other Nodes in here~
</PiccoOption>
<PiccoOption>
~Other Nodes in here~
</PiccoOption>
<PiccoOption>
~Other Nodes in here~
</PiccoOption>
<PiccoOption>
~Other Nodes in here~
</PiccoOption>
</Returning>
</PiccoReply>
Basically I am trying to delete some of the picco option nodes in both the 'Departing' and 'Returning' nodes. All options should be deleted
except the one that i selected.
However, i am getting an error on this line:
xmlDoc.firstChild.firstChild.selectNodes("Departin g").removeChild(oNode_D.item(i));
"Object doesn't support this property or method"
Any help appreciated.
Picco
www.crmpicco.co.uk
www.ie7.com