Oops, minor correction, that should be length - 1 in the initial state of the loop (although the AVM doesn't complain about the deletion of an undefined entity). var xmlList:XMLList = xml..*.(attribute("id") == "6" || attribute("id") == "24"); for (var i:int = xmlList.length() - 1; i >= 0; i--) { delete xmlList[i]; }
________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Peter Farland Sent: Wednesday, May 16, 2007 5:26 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] finding and removing nodes from xml Does something like this work (based on your original email)? The trick is to loop over the XMLList backwards so that you don't have to correct the index each time the list gets smaller from the delete operation. var xmlList:XMLList = xml..*.(attribute("id") == "6" || attribute("id") == "24"); for (var i:int = xmlList.length(); i >= 0; i--) { delete xmlList[i]; } ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Grant Davies Sent: Wednesday, May 16, 2007 4:38 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] finding and removing nodes from xml thanks peter, that using a literal delete... waht if you do delete via reference... e.g. node:XMLNode = xml.tagName["@id=3"]; if you delete node you've you tried to delete the new reference... how do you delete the tag with an id attribute of 3? Grant <http://www.bluetube.com/bti/images/small.jpg> ................................................... > b l u e t u b e i n t e r a c t i v e .: The connection between creative and engineering .: grant davies .: 404.428.6839 (c) .: 708-983-1577 (F) > [EMAIL PROTECTED] > http://www.bluetube.com/bti <http://www.bluetube.com/bti> ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Peter Farland Sent: Wednesday, May 16, 2007 3:18 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] finding and removing nodes from xml http://livedocs.adobe.com/flex/2/langref/operators.html#delete_(XML <http://livedocs.adobe.com/flex/2/langref/operators.html#delete_(XML> ) ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Grant Davies Sent: Wednesday, May 16, 2007 3:05 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] finding and removing nodes from xml I'm trying to find the most correct and efficient syntax to find nodes with a particular attribute value and remove them from an xml document.. suppose my xml is : <code> <response> <status-code>0</status-code> <status-message><![CDATA[ The call was successful ]]></status-message> <recipients> <recipient id="5" firstName="John" lastName="Smith">[EMAIL PROTECTED] <mailto:john%40blah.com> </recipient> <recipient id="6" firstName="firstName" lastName="lastName">[EMAIL PROTECTED] <mailto:chuck%40blah.com> </recipient> <recipient id="23" firstName="grant" lastName="davies">[EMAIL PROTECTED] <mailto:grant%40blue.com> </recipient> <recipient id="24" firstName="fool" lastName="me">[EMAIL PROTECTED] <mailto:grant%40fool.com> </recipient> <recipient id="25" firstName="frick" lastName="frack">[EMAIL PROTECTED] <mailto:frick%40fool.com> </recipient> <recipient id="26" firstName="grant" lastName="davees">[EMAIL PROTECTED] <mailto:firday%40nowhere.com> </recipient> </recipients> </response> </code> And I want to find recipients with an id of 6 and 23 and remove them from the xml... What is the syntax for this? I can find those nodes into an XMLList fine... Its removing them I'm having fun with.. Cheers, Grant