콤보 박스를 위해 XML Dataprovider를 설정하는 데 문제가 있습니다
-
11-09-2019 - |
문제
PHP 파일을 사용하여 Combobox의 드롭 다운 목록을 얻으려고합니다. PHP 파일은 Combobox의 데이터 제공 업체로 사용 된 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의 루트 요소이므로 인터페이스 .lastresult == ifaces라는 것입니다. 따라서 원하는 xmllist는 interfaces.lastresult.iface입니다.
이것은 나에게 일하는 전체 메인 클래스입니다.
` u003Cmx:Application xmlns:mx="http://www.adobe.com/2006/mxml" nlayout="vertical"ninitialize="{interfaces.send();}">
u003Cmx:HTTPService id="interfaces" url="interfaces.xml" resultFormat="e4x" method="POST"> n u003C/mx:HTTPService>
u003Cmx:ComboBox dataProvider="{interfaces.lastResult.iface}" labelField="option"/>
u003C/mx:Application>`