コンボボックスの XML データプロバイダーの設定に関する問題
-
11-09-2019 - |
質問
PHPファイルを使用してコンボボックスのドロップダウンリストを取得しようとしています。その php ファイルは、コンボボックスのデータプロバイダーとして使用された XML 文字列を返します。
私はついていきます このスレッド それも無駄だった。
詳細
mx:Application の CreationComplete 属性を init() に設定しました。init() 関数で次の HTTPService を送信しました
<mx:HTTPService id="interfaces" url="interfaces.php" resultFormat="e4x" method="POST">
</mx:HTTPService>
コンボボックス:
アップデート:XML は次のようになります。
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<ifaces>
<iface>
<option>eth0</option>
</iface>
<iface>
<option>eth1</option>
</iface>
</ifaces>
しかし、ブラウザでinterfaces.phpを実行すると、表示されるのは eth0eth1 です 一方、私はXMLデータ全体を含む文字列をエコーしています。XML 型の文字列全体を表示すべきではないでしょうか?:(
解決
問題は、ifaces が XML のルート要素であるため、interfaces.lastResult == ifaces であることです。したがって、必要な XMLList は、interfaces.lastResult.iface です。
これは私にとって機能するメインクラス全体です。
'<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" initialize="{interfaces.send();}">
<mx:HTTPService id="interfaces" url="interfaces.xml" resultFormat="e4x" method="POST"です> </mx:HTTPService>
<mx:ComboBox dataProvider="{interfaces.lastResult.iface}" labelField="option"/>
</mx:アプリケーション>`