FLEX 从外部读取XML 绑定到控件
代码
<?xml version="1.0" encoding="utf-8"?>
<root>
<myitem>
<Country>USA</Country>
<Gold>35</Gold>
<Silver>22</Silver>
<Des><![CDATA[
USA. dfd fdfd kefjle felkfels dsfsdfdl
sdflsk1231231232
ddkll sdfsdfsd
dfdfdfdfdf 2 fewlkefjw wfefkefwjfewf
]]>
</Des>
</myitem>
<myitem>
<Country>China</Country>
<Gold>22</Gold>
<Silver>33</Silver>
<Des><![CDATA[
China. dfd fdfd kefjle felkfels dsfsdfdl
sdfdcscsdvsdv
ddkll sdfsdfsddvdvd
dfdfdfdfdf 2 fedvdvwlkefjw wfefkefwjfewf
]]></Des>
</myitem>
<myitem>
<Country>Russia</Country>
<Gold>55</Gold>
<Silver>23</Silver>
<Des><![CDATA[
Russia. dsfsdfsdfsdels dsfsdfdl
ssdfd222dfdcscsdd vsdv dsfsdfs
dddfdsfkll sdfsdfsddvdvd sdfsdf
d222fdfdfdfdf 2 fedddvdvwlkefjw wfefkefwjfewf
]]></Des>
</myitem>
</root>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="m_http.send()" width="600">
<mx:ComboBox x="227" y="162" id="m_list" dataProvider="{m_xml}" width="163" labelField="Gold"></mx:ComboBox>
<mx:HTTPService id="m_http" resultFormat="e4x" url="http://localhost/abc.xml"></mx:HTTPService>
<mx:XMLListCollection id="m_xml" source="{m_http.lastResult.myitem}"></mx:XMLListCollection>
</mx:Application>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="m_http.send()" width="600">
<mx:HTTPService id="m_http" resultFormat="e4x" url="http://localhost/abc.xml"></mx:HTTPService>
<mx:XMLListCollection id="m_xml" source="{m_http.lastResult.myitem}"></mx:XMLListCollection>
<mx:DataGrid id="dg1" x="10" y="15" width="580" height="127" dataProvider="{m_xml}">
<mx:columns>
<mx:DataGridColumn headerText="国家" dataField="Country"/>
<mx:DataGridColumn headerText="黄金" dataField="Gold"/>
<mx:DataGridColumn headerText="白银" dataField="Silver"/>
</mx:columns>
</mx:DataGrid>

浙公网安备 33010602011771号