Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Reading XML with Flex

Former Member
0 Kudos

Ok I've gone through Ed's awesome Flex tutorial in the wiki but for some reason I simply can't nail this one.


	<mx:Label y="10" text="Craig's Movie List" id="lblTitle" enabled="true" horizontalCenter="0" fontSize="19" fontFamily="Arial" fontWeight="bold" fontStyle="italic"/>
	
     <mx:HTTPService id="httpRSS" url="http://creator.zoho.com/ccmehil/rss/30/" resultFormat="e4x" />
     
     <mx:DataGrid id="entries" verticalCenter="11" horizontalCenter="0" width="480" dataProvider="{httpRSS.lastResult.channel.item}" height="230">
		<mx:columns>
			<mx:DataGridColumn headerText="Name" dataField="title" width="300"/>
            <mx:DataGridColumn headerText="Rating" dataField="zc:Rating" width="50"/>
            <mx:DataGridColumn headerText="Type" dataField="zc:Genre"/>
            <mx:DataGridColumn headerText="Runtime" dataField="zc:Runtime"/>
		</mx:columns>
	 </mx:DataGrid>

The RSS looks like



<item>
  <title>Winnie the Pooh - A New friend for Winnie Pooh</title>
  <link><a href="http://creator.zoho.com/ccmehil/view/30/record/7987000000110023/" TARGET="test_blank">http://creator.zoho.com/ccmehil/view/30/record/7987000000110023/</a></link>
  <description><b>Title</b> : Winnie the Pooh - A New friend for Winnie Pooh<br/><b>Genre</b> : Zeichentrick<br/><b>Rating</b> : G<br/><b>Director</b> : <br/><b>Year</b> : <br/><b>Runtime</b> : 65<br/><b>Status</b> : Available</description>
  <guid isPermaLink="true"><a href="http://creator.zoho.com/ccmehil/view/30/record/7987000000110023/" TARGET="test_blank">http://creator.zoho.com/ccmehil/view/30/record/7987000000110023/</a></guid>
  <zc:Title>Winnie the Pooh - A New friend for Winnie Pooh</zc:Title>
  <zc:Genre>Zeichentrick</zc:Genre>
  <zc:Rating>G</zc:Rating>
  <zc:Director></zc:Director>
  <zc:Year></zc:Year>
  <zc:Runtime>65</zc:Runtime>
  <zc:Status>Available</zc:Status>
</item>

So why can't I access the zc elements? What am I missing?

1 ACCEPTED SOLUTION

athavanraja
Active Contributor
0 Kudos
12 REPLIES 12

athavanraja
Active Contributor
0 Kudos

0 Kudos

I must not have something right


	<mx:Label y="10" text="Craig's Movie List" id="lblTitle" enabled="true" horizontalCenter="0" fontSize="19" fontFamily="Arial" fontWeight="bold" fontStyle="italic"/>
	
	 <mx:Script>
        <![CDATA[
          private var zc:Namespace = new Namespace("http://creator.zoho.com/ccmehil/rss/30/");
        
     
	
	
     
     
     
		
			
            
            
            
		
	 
]]>

namespace defined but either I defined it wrong or I can't access the element like that in the "datafield"?

0 Kudos

Hi Craig,

I don't think the DataGridColumn really likes dealing with namespaces for the dataField. As an alternative, try using the labelFunction instead. See sample below:


     <mx:Label y="10" text="Craig's Movie List" id="lblTitle" enabled="true" horizontalCenter="0" fontSize="19" fontFamily="Arial" fontWeight="bold" fontStyle="italic"/>
	
     <mx:Script>
         <![CDATA[
              import mx.controls.dataGridClasses.DataGridColumn;
              private var zc:Namespace = new Namespace("http://creator.zoho.com/rss/");
          
              public function ratingReturn(item:XML, column:DataGridColumn):String{
                  return item.zc::Rating;
              }
          
     
	
	
     
     
     
         
		
                
	 
     	
]]>

0 Kudos

Thanks Eddie! Seems the Namespace URL was the biggest issue


<mx:Label y="10" text="Craig's Movie List" id="lblTitle" enabled="true" horizontalCenter="0" fontSize="19" fontFamily="Arial" fontWeight="bold" fontStyle="italic"/>
	
     <mx:Script>
         <![CDATA[
              import mx.controls.dataGridClasses.DataGridColumn;
              private var zc:Namespace = new Namespace("http://creator.zoho.com/rss/");
          
              public function ratingReturn(item:XML, column:DataGridColumn):String{
                  return item.zc::Rating;
              }
              public function ratingGenre(item:XML, column:DataGridColumn):String{
                  return item.zc::Genre;
              }
              public function ratingRuntime(item:XML, column:DataGridColumn):String{
                  return item.zc::Runtime;
              }              
           
     
	
	
     
     
     
       
		
        
        
        
	   
     	
]]>

0 Kudos

In case anyone is wondering about what all this is...


     <mx:Label y="10" text="Craig's Movie List" id="lblTitle" enabled="true" horizontalCenter="298" fontSize="19" fontFamily="Arial" fontWeight="bold" fontStyle="italic"/>
	
     <mx:Script>
         <![CDATA[
         	  import com.adobe.net.URI;
              import mx.controls.dataGridClasses.DataGridColumn;
              import mx.utils.StringUtil;
              
              private var zc:Namespace = new Namespace("http://creator.zoho.com/rss/");
              [Bindable] private var rssSearchStr:String = "http://creator.zoho.com/ccmehil/rss/30/&7987000000030975={0}&7987000000030975_op=26&searchCrit=true&fcid=null&isAscend=null/";
              [Bindable] private var rssTitleSearchStr:String = "http://creator.zoho.com/ccmehil/rss/30/&7987000000030971={0}&7987000000030971_op=26&searchCrit=true&fcid=null&isAscend=null/";
              [Bindable] private var rssStr:String = "http://creator.zoho.com/ccmehil/rss/30/";
              [Bindable] private var rssURI:String = "http://creator.zoho.com/ccmehil/rss/30/";
          
              public function ratingReturn(item:XML, column:DataGridColumn):String{
                  return item.zc::Rating;
              }
              public function ratingGenre(item:XML, column:DataGridColumn):String{
                  return item.zc::Genre;
              }
              public function ratingRuntime(item:XML, column:DataGridColumn):String{
                  return item.zc::Runtime;
              }    
              public function searchRSS():void{
               httpRSS.clearResult();
               txtTitleSearch.text = "";
               var str:String = rssSearchStr;
               str = StringUtil.substitute(str, txtSearch.text);
               rssURI = str;
               httpRSS.send();
              }
              public function searchTitleRSS():void{
               httpRSS.clearResult();
               txtSearch.text = "";
               var str:String = rssTitleSearchStr;
               str = StringUtil.substitute(str, txtTitleSearch.text);
               rssURI = str;
               httpRSS.send();
              }          
              public function latestRSS():void{
              	rssURI = rssStr;
              	httpRSS.send();
              }  
           
     
	
	
     
     
     
       
		
        
        
        
	   
     	
     
     
     
     
     

     
          
     
     
]]>

what I'm working on now is the ablilty to "login" and edit the records via the Flex app as well. Since Zoho Creator now has an API that was the whole point really but again just a test but does open up several new doors for things in the community on "quick turn around"

0 Kudos

0 Kudos

cool!

0 Kudos

Raja,

Damn Damn helpful.

Thanks a ton

Cheers

Abesh

0 Kudos

Here we go a real live test of my first Flex web app

http://webaura.info/flex/movies/Craig_Movies.html

0 Kudos

Pretty cool! -:D But it's also kinda empty -:P Anyway...Good job! It's nice to see that your are improving your Flex skills! Must do the same myself...Just need more time to do all things I must do -:(

Greetings,

Blag.

0 Kudos

only when I run outside of my local environment.