Can someone help me whit this?
it always remove the first node <nick> no matter the value of "i"
jscript code:
var xml = new ActiveXObject("Microsoft.XMLDOM");
var xml2 = new ActiveXObject("Microsoft.XMLDOM");
var xmlIndent = new ActiveXObject("Microsoft.XMLDOM");
xmlIndent.async = false;
xmlIndent.loadXML(xsl);
xml.async = false;
xml.load(logFile);
var node= xml.getElementsByTagName("Nicknames")[0];
var y;
Debug.Trace(node.childNodes.length);
for(var i=0; i<node.childNodes.length; i++)
{
if( node.childNodes[i].childNodes[0].nodeValue = window.LstView_GetItemText("LsvNicks", Index, 0) )
{
>>>y=xml.getElementsByTagName("Nick")[i];<<<
>>>node.removeChild(y);<<<
>>>Debug.Trace("entro!!");<<<
break;
}
}
xml.transformNodeToObject(xmlIndent, xml2);
xml2.save(logFile);
the XML archive
xml code:
<?xml version="1.0" encoding="UTF-8"?>
<Nicknames>
<Nick>uno</Nick>
<Nick>dos</Nick>
<Nick>tres</Nick>
<Nick>cuatro</Nick>
<Nick>cinco</Nick>
<Nick>seis</Nick>
</Nicknames>
I find the problem
jscript code:
var xml = new ActiveXObject("Microsoft.XMLDOM");
var xml2 = new ActiveXObject("Microsoft.XMLDOM");
var xmlIndent = new ActiveXObject("Microsoft.XMLDOM");
xmlIndent.async = false;
xmlIndent.loadXML(xsl);
xml.async = false;
xml.load(logFile);
var node= xml.getElementsByTagName("Nicknames")[0];
var y;
Debug.Trace(node.childNodes.length);
for(var i=0; i<node.childNodes.length; i++)
{
if( node.childNodes[i].childNodes[0].nodeValue[b] == [/b]window.LstView_GetItemText("LsvNicks", Index, 0) )
{
y=xml.getElementsByTagName("Nick")[i];
node.removeChild(y);
Debug.Trace("borrado");
Debug.Trace(i)
break;
}
}
xml.transformNodeToObject(xmlIndent, xml2);
xml2.save(logFile);