开发者

RSS to JSON phonegap

开发者 https://www.devze.com 2023-03-18 08:59 出处:网络
I\'m writing a phonegap application (i.e. no cross domain restrictions for AJAX) that needs to parse RSS feeds (i.e. extract information), I was looking for an easy way to do this. I looked at this, w

I'm writing a phonegap application (i.e. no cross domain restrictions for AJAX) that needs to parse RSS feeds (i.e. extract information), I was looking for an easy way to do this. I looked at this, which seems good, but, I开发者_如何学运维 would rather not connect to external sources since the app should run on pretty slow internet connections too and each extra connection is a problem. What do you guys suggest? JSON seems like an excellent idea, but, any direct ideas are great as well.


I had the same issue. But I don't recommend processing the RSS on each call... This is madness. Neither do I recommend loading the whole RSS as JSON... It's even worst. Those techniques add delay to a connection which might be really slow.

What I did was a bit more complicated but you have full control over what you send.

I'll assume that before loading any articles you'll show a list of titles to choose from...

So, first of all, you need to parse the whole RSS with php (or other server side language) and you'll output JSON formatted text files: 1. A text file containing the list of all articles with their id and title (img path, date, if needed) 2. A text file for each article named rssfeed_[id]

You put a CRON task on that script and ensure that everything is gzipped.

Then you create a small php file to handle the name & id of your file as parameters (that you'll get from the list).

Finally in your application you call one unique php file that will get dynamically any file needed without any processing of XML (RSS) to JSON

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号