Error in rssreader using yql

You must Login before you can answer or comment on any questions.

I am making a rssreader using yql.I have checked the output using yahoo console and it is perfectly alright but it is not working on my titanium and giving error that cannot read property element value of null plz chech out my code

var tableView = Titanium.UI.createTableView(); win3.add(tableView);

var Row = []; Titanium.Yahoo.yql('select * from html where url="http://afghanskills.com/all-jobs.php" and xpath="//tbody/tr/td/a/font/text()" limit 25', function(e) { var results = e.data.item;

for(var i = 0; i < results.length; i++) 

for(var i = 0; i < results.length; i++) {//--- var rss = results[i];

    var rssRow = Titanium.UI.createTableViewRow({
        height : 150,

    });
    var titleLabel = Titanium.UI.createLabel({
        text : rss.title,
        font : {
            fontSize : 16,
            fontWeight : 'bold'
        },
        width : 'auto',
        top : 5,
        left : 40,
        height : 16
    });



    rssRow.add(titleLabel);


   // rssRow.className = 'rssrow';
    Row.push(rssRow);
};

tableView.setData(Row);//---

});

1 Answer

Accepted Answer

The YQL query needs some work -- see this SO post for more info. Here's a start:

//creating main window
var win = Ti.UI.createWindow({
    backgroundColor : '#ededed'
});
 
var tableView = Titanium.UI.createTableView();
win.add(tableView);
var Row = [];
Titanium.Yahoo.yql('select * from html where url="http://afghanskills.com/all-jobs.php" and xpath="//tbody/tr/td/a/font" limit 25', function(e) {
    var results = e.data.font;
 
    for (var i = 0; i < results.length; i++) {
        var rss = results[i];
        var rssRow = Titanium.UI.createTableViewRow({
            height : 150,
            className : 'rssrow'
 
        });
        var titleLabel = Titanium.UI.createLabel({
            text : rss.content,
            font : {
                fontSize : 16,
                fontWeight : 'bold'
            },
            width : 'auto',
            top : 5,
            left : 40,
            height : 16
        });
 
        rssRow.add(titleLabel);
 
        Row.push(rssRow);
    };
 
    tableView.setData(Row);
});
 
win.open();

— answered 7 months ago by Adam Paxton
answer permalink
3 Comments
  • Hi i have tried it but it is giving the same error

    — commented 7 months ago by Muhammad Wahhab Mirza

  • Go to YQL console and run several tests on the query. You'll notice that it times out occasionally. Otherwise, the code works for me.

    — commented 7 months ago by Adam Paxton

  • Thanks Adam for your help it really worked out for me

    — commented 7 months ago by Muhammad Wahhab Mirza

Your Answer

Think you can help? Login to answer this question!