Help xml dom .removeChild() - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Help xml dom .removeChild() (/showthread.php?tid=87223)
Help xml dom .removeChild() by psypersky on 11-11-2008 at 07:50 PM
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);
|