var floorplan:XML = <FloorplanData>
<floor name="1">
<dept name="Administration"/>
<dept name="Reception"/>
</floor>
<floor name="2">
<dept name="Human Resources"/>
<dept name="Finance"/>
</floor>
<floor name="3">
<dept name="Marketing"/>
<dept name="Accounting"/>
</floor>
<floor name="4">
<dept name="Sales"/>
<dept name="Legal"/>
</floor>
</FloorplanData>;
var dep:String = "Reception";
trace("floor: ", floorplan.floor.dept.(@name == dep).parent().toXMLString());
//output:
floor: <floor name="1">
<dept name="Administration"/>
<dept name="Reception"/>
</floor>
Is that what you're looking for?
regards,
Muzak
----- Original Message -----
From: "Mendelsohn, Michael" <michael.mendels...@fmglobal.com>
To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
Sent: Thursday, April 30, 2009 8:43 PM
Subject: [Flashcoders] E4X question
Hi list...
I'm still relatively new with E4X. I can't get seem to get this function to return the name of the floor that the department is
on. I.E., pass a string, traverse the xml, get the parent's name attribute. In my second attempt, I figured to test for the
property name first, because the root node doesn't have @name, but still no luck. This should be easy, right? It's probably
obvious.
Thanks,
- Michael M.
private function getFloor(deptName:String):void{
// always errors
var theFilteredList:XMLList = FloorplanData..*.(@name==thisLabel);
// this doesn't work either
var f:XMLList = FloorplanData.*.(hasOwnProperty("name") &&
attribute("name")==thisLabel);
}
<?xml version="1.0" encoding="utf-8"?>
<FloorplanData>
<floor name="1">
<dept name="Administration"/>
<dept name="Reception"/>
</floor>
<floor name="2">
<dept name="Human Resources"/>
<dept name="Finance"/>
</floor>
<floor name="3">
<dept name="Marketing"/>
<dept name="Accounting"/>
</floor>
<floor name="4">
<dept name="Sales"/>
<dept name="Legal"/>
</floor>
</FloorplanData>
_______________________________________________
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