Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
hervebags
Posts: 6
Registered: ‎12-05-2012
My Device: BB10 Dev Alpha

Having problems loading rss feeds

Hi,

 

I am using this rss url: http://www.carmag.co.za/block.php?b_id=1090&t=8

 

I am using this code, taken straight  from "Sorted Data Model Tutorial":

import bb.cascades 1.0
import bb.data 1.0
   
Page {
    content: ListView {
        id: myListView
      
        // Associate the list view with the data model that's defined in the
        // attachedObjects list
        dataModel: dataModel
      
        listItemComponents: [
            ListItemComponent {
                type: "item"
          
                // Use a standard list item to display the data in the data
                // model
                StandardListItem {
                    //reserveImageSpace: false
                    title: ListItemData.title
                    description: ListItemData.pubDate
                }
            }
        ]
    }
    
    attachedObjects: [
        GroupDataModel { 
            id: dataModel
              
            // Sort the data in the data model by the "pubDate" field, in
            // descending order, without any automatic grouping
            sortingKeys: ["pubDate"]
            sortedAscending: false
            grouping: ItemGrouping.None 
        },
        DataSource {
            id: dataSource
              
            // Load the XML data from a remote data source, specifying that the
            // "item" data items should be loaded
            source: "http://news.google.com/news?topic=h&output=rss"
            //source: "http://www.carmag.co.za/block.php?b_id=1090&t=8"
            query: "/rss/channel/item"
            type: DataSourceType.Xml
        
            onDataLoaded: {
                // After the data is loaded, clear any existing items in the data
                // model and populate it with the new data
                dataModel.clear();
                dataModel.insertList(data)
            }
        }
    ]
    
    onCreationCompleted: {
        // When the top-level Page is created, direct the data source to start
        // loading data
        dataSource.load();
    }
}

 

The Google rss feed works fine but, my rrs link shows a blank page.

I looked at the rrs sample but, it looks very confusing.

 

Does anyone have suggestions.

Developer
raffi
Posts: 154
Registered: ‎06-23-2012
My Device: Z10 & Z30

Re: Having problems loading rss feeds

Try using this url instead: http://www.carmag.co.za/category/news/feed/ and see if that works. The URL you're feeding it is actually re-directing to another URL and it actually was feeding the ATOM feed by default.
New Contributor
hervebags
Posts: 6
Registered: ‎12-05-2012
My Device: BB10 Dev Alpha

Re: Having problems loading rss feeds

Thanks!

That works!

 

I am facing another problem.

 

I'd like to display the 'descriptions' of each items on a ListView.

I'm still using the same rss url:

http://www.carmag.co.za/category/news/feed/

 

The descriptions on the rss file look like this:

<item>
<description>
<![CDATA[
<img width="216" height="122" src="http://www.carmag.co.za/wp-content/uploads/2013/01/16-216x122.jpg" class="attachment-thumbnail wp-post-image" alt="Is this the production-ready Honda NSX?" title="Is this the production-ready Honda NSX?" /><br> <p>Whether it was planned or not, hours before Honda was about to showcase a follow-up concept of the new NSX sportscar, these pictures of what may be a production-spec Acura (Honda) NSX have leaked onto the &#8216;web. From what we can gather, subtle changes have been made to the car’s exterior. But, more importantly, these &#8230; <a href="http://www.carmag.co.za/news/production-ready-honda-nsx/"></a></p><p>The post <a href="http://www.carmag.co.za/news/production-ready-honda-nsx/">Is this the production-ready Honda NSX?</a> appeared first on <a href="http://www.carmag.co.za">CarMag.co.za</a>.</p>
]]>
</description>
</item>

 

 

I tried this:

description: ListItemData.description.p

 It seems to not work

 

Just one last question; To get the image, will i have to do this:

ListItemData.description.img.src

 

 

Thanks,

 

Regards,

 

Herve