C
crmpicco
I am trying to delete all 'PiccoOption' nodes that i do not need, i
then want to put the document, with just one 'PiccoOption' into the
form field 'document.form.optionNumber.value'.
This code doesnt seem to work.....
Any help appreciated.
My XML document:
then want to put the document, with just one 'PiccoOption' into the
form field 'document.form.optionNumber.value'.
This code doesnt seem to work.....
Any help appreciated.
Code:
function loadXML()
{
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0");
xmlDoc.async="false";
xmlDoc.loadXML(document.form.optionXML.value); // The XML file (e.g.
'<PiccoReply><PiccoOption>....etc......')
var optNo = parseFloat(document.form.optionNumber.value); // An
integer
if (xmlDoc.documentElement.hasChildNodes)
{
var iNoOfOpts =
parseFloat(xmlDoc.documentElement.selectNodes("PiccoOption").length);
for (i=0; i<iNoOfOpts; i++)
{
if (i!=optNo)
{
alert("Ref = " +
xmlDoc.documentElement.selectNodes("PiccoOption").item(i).selectNodes("Details").item(0).selectNodes("Ref").item(0).text);
alert("i = " + i);
alert("optNo = " + optNo);
var delNode = xmlDoc.documentElement.childNodes
delNode.removeChild(true);
}
}
}
}
My XML document:
Code:
<PiccoReply>
<PiccoOption>
<Details>
<JourneyType>RETURN</JourneyType>
<Ref>59</Ref>
</Details>
</PiccoOption>
<PiccoOption>
<Details>
<JourneyType>GLASGOW</JourneyType>
<Ref>9</Ref>
</Details>
</PiccoOption>
<PiccoOption>
<Details>
<JourneyType>IRVINE</JourneyType>
<Ref>9</Ref>
</Details>
</PiccoOption>
</PiccoReply>