
114 Retrieve and Display Data
Some nodes have child nodes containing data, including the “title” child node of the
channel node. The lastResult object of the HTTPService component
(
feedRequest.lastResult) reflects this structure:
feedRequest.lastResult.rss.channel.title
Your code should look like the following example:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="feedRequest.send()" layout="absolute">
<mx:HTTPService
id="feedRequest"
url="http://weblogs.macromedia.com/mchotin/index.xml"
useProxy="false" />
<mx:Panel x="10" y="10" width="475" height="400"
title="{feedRequest.lastResult.rss.channel.title}">
<mx:DataGrid id="dgPosts" x="20" y="20" width="400">
<mx:columns>
<mx:DataGridColumn headerText="Column 1"
dataField="col1"/>
<mx:DataGridColumn headerText="Column 2"
dataField="col2"/>
<mx:DataGridColumn headerText="Column 3"
dataField="col3"/>
</mx:columns>
</mx:DataGrid>
<mx:TextArea x="20" y="175" width="400"/>
<mx:LinkButton x="20" y="225" label="Read Full Post"/>
</mx:Panel>
</mx:Application>
4.
Save the file, wait until Flex Builder finishes compiling the application, and then click the
Run button in the toolbar to test the application.
A browser opens and runs the application. The blog’s title, Matt Chotin, should appear as
the title of the Panel control, indicating that the application successfully retrieved data
from the RSS feed.
NOTE
There may be a delay of a few seconds before the title appears while the application
is contacting the server.
Comentarios a estos manuales