<?xml version="1.0" encoding="utf-8"?>
<students>
<student name="jimmy" id="111">
<grade id="math">100</grade>
<grade id="history">120</grade>
</student>
<student name="lucy" id="222">
<grade id="arts">130</grade>
<grade id="biology">140</grade>
</student>
</students>
</countries>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white">
<mx:XML id="dp" source="student_grade.xml" format="e4x" />
<mx:Script>
<![CDATA[
import mx.controls.Alert;
private function clickHandle():void
{
var o:Object = student.selectedItem;
var s:String = student.selectedItem.@id;
trace(student.selectedItem.@id);
var oo:Object = grade.selectedItem;
trace(grade.selectedItem.@id);
}
]]>
</mx:Script>
<mx:Form>
<mx:FormItem label="Student:">
<mx:ComboBox id="student" dataProvider="{dp.student}" labelField="@name" />
</mx:FormItem>
<mx:FormItem label="Grade:">
<mx:ComboBox id="grade" dataProvider="{student.selectedItem.grade}" />
</mx:FormItem>
</mx:Form>
<mx:Button click="clickHandle()"/>
</mx:Application>