0

我正在尝试使用 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 类型的字符串吗?:(

4

1 回答 1

1

问题是 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:应用程序>`

于 2009-11-02T13:30:39.727 回答