代码之家  ›  专栏  ›  技术社区  ›  StuBlackett

从XML中选择一个特定数据项

  •  0
  • StuBlackett  · 技术社区  · 16 年前

    我在一个星期的示例中遵循了flex,使用了将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>
    

    提前多谢……

    1 回复  |  直到 16 年前
        1
  •  1
  •   Amarghosh    16 年前

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

    <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>
    
    推荐文章