Hi,
You can use:
var myNode:String = "background";
var myAttr:String = "url";
var foo:XML = customXML.config.child(myNode).attribute(myAttr);
Or similar. You should possibly handle exceptions - e.g. if config
does not have any background nodes, that will go pear shaped, etc.
e.g.
var foo:XMLList = customXML.config.child(myNode);
if(0 == foo.length()) {
trace("no XML nodes with type '" + myNode + "'");
return;
}
var bar:XMLList = foo[0].attribute(myAttr);
if(0 == bar.length()) {
trace("no XML nodes with attr '" + myAttr + "'");
return;
}
trace("found " + bar.length() + " nodes of " + myNode + " with attr
" + myAttr " + bar.toXMLString());
Have a play with some of the tools online:
http://www.linkwerk.com/pub/javascript/e4x/e4x-tester/
Works quite nicely and seems to support most "queries".
http://blog.betabong.com/2008/09/23/e4x-string-parser/
Only supports parsing some e4x "queries", but is okay for testing
basic stuff.
I keep turning to this article, which is really helpful for e4x
stuff time-and-time again:
http://dispatchevent.org/roger/as3-e4x-rundown/
These might be helpful for info about "filtering" e4x:
http://joshblog.net/2007/05/17/filter-xml-data-with-e4x-in-flash-part-2/
http://joshblog.net/2007/06/29/getting-advanced-with-e4x/
http://keith-hair.net/blog/2008/05/31/using-e4x-with-xml-in-as3/
HTH
Glen
http://www.google.co.uk/search?hl=en&client=firefox-a&hs=aWx&rls=org.mozilla%3Aen-US%3Aofficial&channel=s&q=as3+e4x+filtering+comparison&meta=&aq=f&aqi=&aql=&oq=
Steven Loe wrote:
In E4X we use dot notation to access a node in an XML:
var foo = customxml.config.backgrou...@url
Is it possible to substitute variables in portions of the path above? Something
like this:
var myNode = "background";
var myAttr = @url;
var foo = customXML.config.[myNode].[myAttr];
Possible?
Thanks very much
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
--
Glen Pike
01326 218440
www.glenpike.co.uk <http://www.glenpike.co.uk>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders