Posted By

chrisaiv on 02/26/09


Tagged

xml as3 mxml e4x


Versions (?)

Flex: Simple RSS Parser


 / Published in: MXML
 

URL: http://www.theflexshow.com/blog/index.cfm/2008/8/20/The-Flex-Show--Fifteen-Minutes-With-Flex--Episode-5--Using-XML-With-Flex

Simple example of parsing an RSS feed

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="800" height="500" creationComplete="onCreationComplete()">
  3. <mx:Script>
  4. <![CDATA[
  5. import mx.rpc.events.ResultEvent;
  6.  
  7. [Bindable]
  8. private var rssResults:XML;
  9.  
  10. private function onCreationComplete():void
  11. {
  12. httpService.send();
  13. }
  14.  
  15. private function parseRSS( e:ResultEvent ):void
  16. {
  17. rssResults = e.result as XML;
  18. //Display this XML in a DataGrid
  19. trace( rssResults.i );
  20. }
  21.  
  22. ]]>
  23. </mx:Script>
  24. <mx:HTTPService id="httpService"
  25. url="http://feeds2.feedburner.com/TheFlexShow-FifteenMinutesWithFlex-Screencast?format=xml"
  26. resultFormat="e4x"
  27. result="parseRSS(event)" />
  28. <mx:DataGrid dataProvider="{rssResults.channel.item}" width="100%">
  29. <mx:columns>
  30. <mx:DataGridColumn dataField="title" />
  31. <mx:DataGridColumn dataField="link" />
  32. <mx:DataGridColumn dataField="category" />
  33. <mx:DataGridColumn dataField="description" />
  34. </mx:columns>
  35. </mx:DataGrid>
  36. </mx:Application>

Report this snippet  

You need to login to post a comment.