query($sql); $apps = array(); while ($row = $result->fetch_assoc()) { $row['category'] = (!$row['category_id'] ? null : $categories[$row['category_id']]); $apps[$row['id']] = $row; } $doc = new DOMDocument('1.0', 'utf-8'); $rss = $doc->createElement('rss'); $rss->setAttribute('version', 0.91); $doc->appendChild($rss); $channel = $doc->createElement('channel'); $rss->appendChild($channel); $title = $doc->createElement('title', 'Обзоры приложений для iPhone & iPad'); $link = $doc->createElement('link', 'http://appchi.ru/apps'); $lang = $doc->createElement('language', 'ru'); $image = $doc->createElement('image'); $image->appendChild($doc->createElement('url', 'http://appchi.ru/images/logo.png')); $image->appendChild($doc->createElement('title', 'Обзоры приложений для iPhone & iPad')); $image->appendChild($doc->createElement('link', 'http://appchi.ru/apps')); $channel->appendChild($title); $channel->appendChild($link); $channel->appendChild($lang); $channel->appendChild($image); foreach ($apps as $app) { $item = $doc->createElement('item'); $title = $doc->createElement('title'); $title->appendChild($doc->createCDATASection($app['title'])); $link = $doc->createElement('link', 'http://appchi.ru/app/'.$app['apps_id'].'-'.translite($app['title'])); $pubdate = $doc->createElement('pubDate', date('D, d M Y H:i:s O', strtotime($app['date']))); ob_start(); require './templates/rss.php'; $description = ob_get_contents(); ob_end_clean(); $description = trim(preg_replace('/\s+/', ' ', $description)); $desc = $doc->createElement('description'); $desc->appendChild($doc->createCDATASection($description)); $item->appendChild($title); $item->appendChild($pubdate); $item->appendChild($link); $item->appendChild($desc); $channel->appendChild($item); } header('Content-type: text/xml; charset=utf-8'); echo $doc->saveXML(); ?>