Wouldnt this work:
for (var
locNode:XMLNode=aNode.firstChild; locNode != null; locNode=locNode.nextSibling){
if
(locNode.nodeType == 1
&& locNode.nodeName=="location"){
var
exclude:Boolean =
false;
if (some
condition here){
exclude
= true;
}
}
if(exclude==true){
var
nextNode =
loclNode.nextSibling;
loclNode.removeNode();
localNode
= nextNode;
}
}
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Dogra, Daman
Sent: donderdag 30 juni 2005 16:39
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Problem using removeNode()
Hi All,
I am facing a Coder's block here and would appreciate help . This is kind of long and I apologize for the same .
Using actionscript I am looping some nodes (called "location") in a XML document and based on some condition would like to remove a few "location" nodes from the XML . Here's my initial code
for (var locNode:XMLNode=aNode.firstChild; locNode != null; locNode=locNode.nextSibling){
if (locNode.nodeType == 1 &&
locNode.nodeName=="location"){
var exclude:Boolean = false;
if (some condition here){
exclude = true;
}
}
if(exclude==true){
loclNode.removeNode();
}
}
The above code does not work, because after removing the first "location" node, the loop is never executed again as loop condition locNode != null is not fullfilled (because the locNode being evaluated just got deleted).
I tried to solve this by having another pointer (called delNode) moving along with locNode and using delNode to remove nodes , while keep moving locNode on to next sibling . The problem I now face is that after delNode deletes a node, I am not able to have it catch up with locNode . Here's the code
for (var locNode:XMLNode=aNode.firstChild; locNode != null;){
if (locNode.nodeType == 1 &&
locNode.nodeName=="location"){
var exclude:Boolean = false;
if (some condition here){
exclude = true;
}
}
if(exclude==true){
locNode=delNode.nextSibling;
delNode.removeNode();
//would like some kind of statement here to have delNode catch up with
locNode
}else{
locNode=locNode.nextSibling;
delNode=delNode.nextSibling;
}
}
Would appreciate any suggestions / modifications.
Thanks
-Daman
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
---- LSpots keywords ?>---- HM ADS ?>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
---- LSpots keywords ?> ---- HM ADS ?>
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.