When you trace out:
trace(staff.*.(POSITION == Designer));
You will see that it returns the parent EMPLOYEE element... So, even
if your code were to work, all it would do would be to return the root
STAFF node, which probably wouldn't help you.
If you compare the two examples, you will see that there is only one
POSITION node within each EMPLOYEE node...
If you modify the staff XML to be:
var staff:XML = STAFF
EMPLOYEE ID=501 HIRED= 109072800
NAMEMarco Crawley/NAME
MANAGERJames Crawley/MANAGER
POSITIONDesigner/POSITION
POSITIONProgrammer/POSITION
/EMPLOYEE
/staff
It will no longer work.
Also, you should be using attributes as opposed to entering values
directly into nodes. I personally never filter e4x through the node
value, but rather through attribute values, like so...
var staff2:XML=STAFF
EMPLOYEE name=fredfred/EMPLOYEE
EMPLOYEE name=bobbob/EMPLOYEE
EMPLOYEE name=leroyleroy/EMPLOYEE
EMPLOYEE name=algernonalgernon/EMPLOYEE
/STAFF
trace(find leroy: +staff2.*.(@name==leroy).toXMLString());
Hope this helps.
- Taka
On Thu, Feb 19, 2009 at 5:22 PM, Ferd Berfel ferd.of.ber...@gmail.com wrote:
hello, newbie here...
I'm trying to understand searching xml with e4x
why does this work:
var staff:XML = STAFF
EMPLOYEE ID=501 HIRED= 109072800
NAMEMarco Crawley/NAME
MANAGERJames Crawley/MANAGER
POSITIONDesigner/POSITION
/EMPLOYEE
/staff
var results:XMLList= staff.*.(POSITION == Designer)
and this does not?
var staff2:XML=STAFF
EMPLOYEEfred/EMPLOYEE
EMPLOYEEbob/EMPLOYEE
EMPLOYEEleroy/EMPLOYEE
EMPLOYEEalgernon/EMPLOYEE
/STAFF
trace(find leroy: +staff2.(EMPLOYEE==leroy));
but more importantly, how WOULD I find leroy? (I know I can create a
function to loop through children, but I'm wondering how to do it within the
format describe)
tia
ferd
___
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