Yes, definitely something weird on your end - something isn't the same
as what you're posting, because if I make sure your XML is well-formed,
the following works perfectly for me and both traces show the same
intended result. Try this in a fresh flash file:
var artData:XML = new XML(<art>
<bios>
<artistBio f="Peter" s="Agrafiotis">An
artist</artistBio>
<artistBio f="Larry" s="Denning">He sucks</artistBio>
<artistBio f="Susan" s="Agrafiotis">She
rocks</artistBio>
</bios>
</art>);
var lastName="Agrafiotis";
var a:XMLList = artData.bios.artistBio.(@s==lastName);
trace("First method: "+a); // correctly finds all s=="Agrafiotis" nodes
var b:XMLList = artData.bios.*.(@s==lastName);
trace("Second method: "+b); // correctly finds all s=="Agrafiotis" nodes
I know you're probably testing this with some other Xml which may look
different - so make sure the structure is truly the same as your
example. Hope that helps,
Jason Merrill
Bank of America Global Learning
Learning & Performance Soluions
Join the Bank of America Flash Platform Community and visit our
Instructional Technology Design Blog
(note: these are for Bank of America employees only)
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
Mendelsohn, Michael
Sent: Friday, February 05, 2010 1:07 PM
To: Flash Coders List
Subject: RE: [Flashcoders] E4X, it's just not my day.
Sorry folks, that was a typo in the post. In my Flash file, it is
indeed correctly formed XML.
var e = artData.bios.artistBio.(@s==lastName);
var d = artData.bios.*.(@s==lastName);
There is something definitely weird going on in my code, because this is
a simple E4X statement. Seriously, shouldn't e and d both return the
one node that fits that criteria? In my class, e returns undefined, and
d correctly returns it.
- MM
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Jer
Brand
Sent: Friday, February 05, 2010 12:16 PM
To: Flash Coders List
Subject: Re: [Flashcoders] E4X, it's just not my day.
Fixing that, your code works (I just added explicit var types).
var artData:XML = new XML(<art>
<bios>
<artistBio f="Peter"
s="Agrafiotis">an artist</artistBio>
<artistBio f="Larry"
s="Denning">He sucks</artistBio>
<artistBio f="Susan"
s="Agrafiotis">She rocks</artistBio>
</bios>
</art>);
var lastName:String="Agrafiotis";
var a:XMLList =
artData.bios.artistBio.(@s==lastName);
trace(a.toXMLString())
var b:XMLList = artData.bios.*.(@s==lastName);
trace(b.toXMLString()) ;
OUTPUTS:
<artistBio f="Peter" s="Agrafiotis">an artist</artistBio>
<artistBio f="Susan" s="Agrafiotis">She rocks</artistBio>
<artistBio f="Peter" s="Agrafiotis">an artist</artistBio>
<artistBio f="Susan" s="Agrafiotis">She rocks</artistBio>
Jer
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders