[Flashcoders] loop to delete XML nodes WAS: Getting bitmap data after successfully loading a swf file

2010-11-30 Thread Mendelsohn, Michael
Sorry list!  I didn't properly title that post!  :-(

- MM



Hi list...

I want loop through to delete certain nodes, but can't figure out how to do it. 
 I've tried a conventional loop, for...in and for...each...in, and I must be 
missing something.

pack
dog id=1/
dog/
dog id=2/
dog/
dog id=3/
/pack

I'd like to delete all instances of dog that don't have an @id, or @id==2.

Any thoughts?
Thanks,
- Michael M.

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] loop to delete XML nodes WAS: Getting bitmap data after successfully loading a swf file

2010-11-30 Thread Kenneth Kawamoto

I have this (rather ugly) solution:

var i:uint = 0;
while(i  xml.dog.length()){
   if(xml.dog[i].attribute(id) != 2){
  delete xml.dog[i];
   } else {
  ++i;
   }
}

My preferred way would be though, is doing it vise versa, i.e. add the 
qualifying nodes instead of deleting not qualifying nodes:


var xml2:XML = pack /;
xml2.appendChild(xml.dog.(attribute(id) == 2));

Kenneth Kawamoto
http://www.materiaprima.co.uk/

On 01/12/2010 05:33, Mendelsohn, Michael wrote:

Sorry list!  I didn't properly title that post!  :-(

- MM



Hi list...

I want loop through to delete certain nodes, but can't figure out how to do it. 
 I've tried a conventional loop, for...in and for...each...in, and I must be 
missing something.

pack
dog id=1/
dog/
dog id=2/
dog/
dog id=3/
/pack

I'd like to delete all instances of dog that don't have an @id, or @id==2.

Any thoughts?
Thanks,
- Michael M.

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders