2 Replies Latest reply on Aug 20, 2011 8:23 AM by kzakarias

    How to display a simple rss feed?




      I've build a simple application that has a httpservice called rss that calls "http://www.nytimes.com/services/xml/rss/nyt/GlobalBusiness.xml" and retrieves the rss feed. Under test operation I can see it returning the feed.


      When the init() function is called the httpservice is called and passed to a datagrid.

      However, when I run it I get the following fault.


      Security error accessing url
      Destination: DefaultHTTP



      In the console I get the following messeage:


      Warning: Domain www.nytimes.com does not specify a meta-policy.  Applying default meta-policy 'master-only'.  This configuration is deprecated.  See http://www.adobe.com/go/strict_policy_files to fix this problem.


      Error: Request for resource at http://www.nytimes.com/services/xml/rss/nyt/GlobalBusiness.xml by requestor from http://localhost:8888/Newsroom-debug/Newsroom.swf/[[DYNAMIC]]/4 is denied due to lack of policy file permissions.


      *** Security Sandbox Violation ***
      Connection to http://www.nytimes.com/services/xml/rss/nyt/GlobalBusiness.xml halted - not permitted from http://localhost:8888/Newsroom-debug/Newsroom.swf
      [Unload SWF] /Newsroom-debug/Newsroom.swf



      I have checked different posts online and in this forum describing crossdomain.xml and settings in the flash player global settings to resolve this issue, but I can for some reason not get it to work.


      I want to be able to take rss feeds from any site and display them in a simple datagrid?

      Any suggestions?


      Below is the application code.






      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"

                creationComplete="init();" xmlns:rss="services.rss.*">

                  import mx.controls.Alert;
                  import mx.events.FlexEvent;
                  import mx.rpc.events.ResultEvent;


                protected function init():void
                      getDataResult.token = rss.getData();

              <s:CallResponder id="getDataResult"/>
              <rss:Rss id="rss" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
          <mx:DataGrid id="rssGrid" width="500" dataProvider="{getDataResult.lastResult.channel.item}" >
                  <mx:DataGridColumn headerText="Feed" dataField="headline" />
                  <mx:DataGridColumn headerText="description" dataField="description"/>

        • 1. Re: How to display a simple rss feed?
          saisri2k2 Level 4

          Let your server code do the job of getting the rss feeds from various resources if this is an issue, normally if you are calling a different domain from your flex app, then that domain should hav a crossdomain.xml(its a flash player thing) allowing your flash player to get access to the xml.


          In this case it is clear that we do not have any permissions to grab their data, so, we have to ask the server code to call the rss feeds(i'm hoping a simple code which just relays your call to the external domain).

          1 person found this helpful
          • 2. Re: How to display a simple rss feed?
            kzakarias Level 1



            Tried out your suggestion and it works!

            Thanks saisri2k2


            1) I created an http service which calls a php file:


                        resultFormat="e4x" />


            2) The php file then gets the feed and passes it back to the rssNewYorkTimes_resultHandler:


              $feed = 'http://www.nytimes.com/services/xml/rss/nyt/GlobalBusiness.xml';
              $rawfeed = @file_get_contents($feed);
              print $rawfeed; 


            3) the resulthandler then processes the feed and puts it in an arraycollection that can be passed to the datagrid:


            protected function rssNewYorkTimes_resultHandler(event:ResultEvent):void
                            var xmlList:XMLList = event.result.channel.item as XMLList;
                            for each(var item:XML in xmlList)

                                rssCollection.addItem({title: item.title, description:item.description, source:item.link});


            Thanks also to Chris Black for his post which explains in detail how this trick is done!