createElement('rss'); $rss->setAttribute('version', 0.91); $doc->appendChild($rss); $channel = $doc->createElement('channel'); $rss->appendChild($channel); $title = $doc->createElement('title', 'Appchi.ru'); $link = $doc->createElement('link', 'http://appchi.ru/blogs'); $lang = $doc->createElement('language', 'ru'); $channel->appendChild($title); $channel->appendChild($link); $channel->appendChild($lang); $stmt = $mysqli->prepare('SELECT id, title, post, date FROM blogs_posts ORDER BY date DESC LIMIT 20'); $stmt->execute(); $stmt->bind_result($id, $postTitle, $postDesc, $date); while ($stmt->fetch()) { $postDesc = preg_replace('/.*$/is', '', $postDesc); $item = $doc->createElement('item'); $title = $doc->createElement('title'); $postTitle = 'Приложение: '.$postTitle; $title->appendChild($doc->createCDATASection($postTitle)); $link = $doc->createElement('link', 'http://appchi.ru/blogs/post/'.$id); $desc = $doc->createElement('description'); $pubdate = $doc->createElement('pubDate', date('D, d M Y H:i:s O', strtotime($date))); $desc = $doc->createElement('description'); $desc->appendChild($doc->createCDATASection($postDesc)); $item->appendChild($title); $item->appendChild($pubdate); $item->appendChild($link); $item->appendChild($desc); $channel->appendChild($item); } $stmt->close(); header('Content-type: text/xml; charset=utf-8'); echo $doc->saveXML(); ?>