That's pretty sweet.  

Jason Merrill 

Bank of  America   Global Learning 
Shared Services Solutions Development 

Monthly meetings on the Adobe Flash platform for rich media experiences
- join the Bank of America Flash Platform Community 





-----Original Message-----
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Steven
Sacks
Sent: Tuesday, June 09, 2009 1:22 PM
To: Flash Coders List
Subject: Re: [Flashcoders] XML find and delete nodes

Once you really dig into E4X and realize the crazy stuff you can do,  
it's amazing.

I do some pretty crazy E4X parsing, filtering and validation with  
Gaia.  Here are some examples:

// get all nodes named page or asset in the entire XML
var nodes:XMLList = xml.descendants().(name() == "page" || name() ==  
"asset");

// from those nodes, find any that don't have both id and src attributes
var invalidNodes:XMLList = nodes.(!attribute("id").length() || ! 
attribute("src").length());

//  get all nodes where id is not alphanumeric or begins with a number
invalidNodes = nodes.(!(/^[a-z_][a-z0-9_]*$/i.test(@id)));

// this one is complex but basically it isolates nodes that do not  
have a valid
// class package path in a package attribute
var packageNodes:XMLList = xml.descendants(). 
(attribute("package").length() > 0);
invalidNodes = packageNodes.(!(/^[a-z][\w\.]*\w+$/ 
i.test(attribute("package"))));


As you can see, combining E4X and RegEx you can do some CRAZY stuff.
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to