> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:flashcoders-
> [EMAIL PROTECTED] On Behalf Of Scott Haneda
> Sent: Thursday, November 09, 2006 1:59 PM
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] Noob, basic questions on actionscript,
> withmethodology suggestions
>
> Thanks, and if my XML looks like this:
> Load in this XML file:
> <camps sport="Tennis">
> <state name="California" cc="3" url="a"/>
> <state name="Oregon" cc="13" url="b"/>
> <state name="Washington" cc="2" url="c"/>
> </camps>
>
> What would be the best way to get myself a set of accessible variables
in
> which I can call out a state name, and get the two remaining
parameters?
Which version of ActionScript are you using?
In 2.0:
function getCCAndURL(xml:XML, stateName:String):Object {
for (var node:XMLNode = xml.firstChild.firstChild; node != null;
node = node.nextSibling) {
if (node.nodeName == "state"
&& node.attributes.name == stateName) {
return {cc: node.attributes.cc,
url:node.attributes.url};
}
}
return {cc: null, url: null};
}
In 3.0:
// Throws an error if more than one <state> node has the same name.
function getCCAndURL(xml:XML, stateName:String):Object {
var state:XMLList = xml.state.(@name == stateName);
return {cc: [EMAIL PROTECTED], url: [EMAIL PROTECTED];
}
Ain't e4x grand?
―
Mike Keesey
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com