Processing RSS/Atom Feeds is one very common use of XML parsing and HTTP/Web technology in Adobe Flex/AIR mobile applications.
Fortunately, ActionScript 3 Programming Language supports E4X, which is XML extensions on top of the programming language itself to make parsing and processing RSS Feeds or Atom documents (which are valid XML documents) very easy.
To develop Adobe AIR applications on Android smartphones easily, I highly recommend Developing Android Applications with Adobe AIR (Adobe Developer Library).
Sample code for parsing RSS/Atom Feeds XML using ActionScript:
<?xml version="1.0" encoding="utf-8"?> <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" overlayControls="false" tabBarVisible="true" title="Home" initialize="homeView_initializeHandler(event)"> <fx:Declarations> <fx:XML id="detikRss2" source="samples/detik_rss2.xml"/> </fx:Declarations> <fx:Script> <![CDATA[ import model.Article; import mx.collections.ArrayList; import mx.events.FlexEvent; import mx.utils.StringUtil; [Bindable] private var articles:ArrayList = new ArrayList([]); protected function homeView_initializeHandler(event:FlexEvent):void { var newArticles: Array = []; for each (var el:XML in detikRss2..item) { var title:String = StringUtil.trim(String(el.title).replace(/\s+/g, " ")); var body:String = StringUtil.trim(String(el.description).replace(/<.*?>/g, " ").replace(/\s+/g, " ")); var article:Article = new Article(title, el.body); article.summary = new String(body).substr(0, 160); article.url = StringUtil.trim(el.link); article.imageUrl = StringUtil.trim(el.enclosure.@url); trace("Parsed", article); newArticles.push(article); } articles.source = newArticles; } ]]> </fx:Script> <s:Scroller top="0" bottom="0" left="0" right="0"> <s:DataGroup itemRenderer="renderer.ArticleRenderer" dataProvider="{articles}" width="100%"> <s:layout> <s:VerticalLayout/> </s:layout> </s:DataGroup> </s:Scroller> </s:View>
Learn more about Mobile Flex Development in Developing Android Applications with Adobe AIR (Adobe Developer Library).
I have no words for this great post such a awe-some information i got gathered. Thanks to Author.
ReplyDeletehtml5 converter