开发者

Easiest method to save external rss feeds

I have big problem, I want to read rss feeds from mydealz.de and save their titles, contents and dates to my db. I'm using cakephp, is there any easy way to do it? I'm simply out of ideas

I was tryin开发者_StackOverflowg to do that from this tutorial : http://www.google.com/url?sa=D&q=http://blog.loadsys.com/2009/06/19/cakephp-rss-feed-datasource/&usg=AFQjCNFhFxVyjqEFoPFfZgt-X2NYpmv0OQ but in model I delclared that I'm not using database.


App::import('Core', 'HttpSocket');
$HttpSocket = new HttpSocket();
$input = $HttpSocket->get('http://www.example.com/something.xml');

App::import('Xml'); 
$xml = new Xml($input);
$xmlAsArray = $xml->toArray();

foreach($xmlAsArray as $item) {
    $this->Article->create();
    $data['Article'] = array(
        'title' => $item['title'],
        'contents' => $item['contents'],
        'date' => $item['date']
    );
    $this->Article->save($data);
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜