【问题标题】:Selecting One Particular Data Item from XML从 XML 中选择一个特定的数据项
【发布时间】:2010-07-12 09:21:20
【问题描述】:

我使用了 Flex in a week 示例,使用下拉菜单将 XML 数据与 XML 节点集配对。

对于我正在创建的项目,我只是将一个仅包含一个节点的 XML 文件拉入我的应用程序。

所以我的问题是,我该如何实现这一目标?

我正在使用 HTTPService 并提取数据,但目前唯一的方法是使用 <s:DropDownList>

我的代码如下:

 <fx:Declarations>
  <!-- Place non-visual elements (e.g., services, value objects) here -->

  <s:HTTPService id="channelList" 
        url="http://www.spriing.dev/videolist/createxml.php" 
        showBusyCursor="true">
  </s:HTTPService>

 </fx:Declarations>
  <s:Group>
   <mx:Image id="backgroundImg" source="{channelSelection.selectedItem.background_image}" width="100%" height="100%" scaleContent="true"/>
  </s:Group>

  <s:Group>
   <mx:FormItem label="Select Your Channel : ">

    <s:DropDownList id="channelSelection" dataProvider="{channelList.lastResult.channels.channel}" labelField="name"  width="196"/>

   </mx:FormItem>

   <s:Label text="{channelSelection.selectedItem.name}"  x="0" y="45" width="331"/>

   <s:Label text="{channelSelection.selectedItem.description}"  x="0" y="72" width="331"/>

   <mx:Image source="{channelSelection.selectedItem.logo}" x="2" y="95" />

</s:Group>

提前非常感谢..

【问题讨论】:

  • 我不确定我是否理解你的问题 - 你在哪里卡住了 - 你是想摆脱下拉列表吗?
  • 是的,没错。我想摆脱下拉列表,让标签在不使用下拉列表的情况下通过 XML 节点拉出。谢谢
  • 我的 XML(如果有帮助的话)如下:Channel One这是 Channel One。 ./img/logo_small.jpg../img/background.jpg

标签: apache-flex flex4


【解决方案1】:

通过将channelSelection.selectedItem 替换为channelList.lastResult.channels.channel 将它们绑定到原始源(HTTPService)

<s:Group>
    <mx:Image id="backgroundImg" width="100%" height="100%" scaleContent="true"
       source="channelList.lastResult.channels.channel.background_image}" />
</s:Group>
<s:Group>

    <s:Label text="{channelList.lastResult.channels.channel.name}"  
        x="0" y="45" width="331"/>

    <s:Label text="{channelList.lastResult.channels.channel.description}"  
        x="0" y="72" width="331"/>

    <mx:Image source="{channelList.lastResult.channels.channel.logo}" x="2" y="95" />

</s:Group>

【讨论】:

  • 我现在如何从 XML 中选择所有数据?基本上我正在做一个IPTV服务。按照您的建议,第一个只是通过 ONE 频道。但是那个频道里有视频,我怎样才能把它们全部拉出来?提前致谢
  • 我认为您正在寻找数据网格、平铺列表或带有适当项目渲染器的简单列表。将此作为新问题发布;不要忘记添加xml的结构。
猜你喜欢
  • 2021-11-03
  • 1970-01-01
  • 2021-08-03
  • 2021-03-04
  • 2021-10-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多