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
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders