有关SupeSite6.0调用数据库问题

dajiuwen 2008-04-05 03:11:46
我想用PHP调用SupeSite资讯某一等级的最新三条数据,并且自动生成xml文件

请问要怎样才能实现呢?具体代码该怎样写?

要生成XML的内容如下:


<?xml version="1.0" encoding="gb2312" standalone="yes" ?>
- <leadspots>
- <pic>
<image>图片附件地址1 </image>
<title>标题1 </title>
<dek>简写内容。。。2 </dek>
<section>资讯根分类名 </section>
<sitepath>文章连接地址1 </sitepath>
<newwindow>False </newwindow>
</pic>
- <pic>
<image>图片附件地址2 </image>
<title>标题2 </title>
<dek>简写内容。。。2 </dek>
<section>资讯根分类名 </section>
<sitepath>文章连接地址2 </sitepath>
<newwindow>False </newwindow>
</pic>- <pic>
<image>图片附件地址3 </image>
<title>标题3 </title>
<dek>简写内容。。。3 </dek>
<section>资讯根分类名 </section>
<sitepath>文章连接地址3 </sitepath>
<newwindow>False </newwindow>
</pic>
<firstvisit>True </firstvisit>
</leadspots>
...全文
97 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
justicesun 2008-04-07
  • 打赏
  • 举报
回复
rss呗
有人写过rss.class.php这个类..你看下吧
google里搜到的 http://www.easemarry.com/blog/rss-class-php/


This is a generation RSS document PHP class

<?php
if (defined(’_CLASS_RSS_PHP’)) return;
define(’_CLASS_RSS_PHP’,1);
/**
* Class name: RSS
* $rss = new RSS(”Blog”,”http://www.easemarry.com/”,”EaseMarry’s Blog”);
* $rss->AddItem(”RSS Class”,”http://www.easemarry.com”,”description”,date());
* $rss->AddItem(…);
* $rss->SaveToFile(”../rss/index.xml”);
*/

class RSS {
var $rss_ver = “2.0″;
var $channel_title = ”;
var $channel_link = ”;
var $channel_description = ”;
var $language = ‘en-us’;
var $copyright = ‘easemarr.com’;
var $webMaster = ‘web@easemarry.com’;
var $pubDate = ”;
var $generator = ‘Easemarry.com’;
var $content = ”;
var $items = array();

function RSS($title, $link, $description) {
date_default_timezone_set(’GMT’);
$this->channel_title = $title;
$this->channel_link = $link;
$this->channel_description = $description;
$this->pubDate = Date(DATE_RFC822);
}

function AddItem($title, $link, $description ,$pubDate) {
$this->items[] = array(’titile’ => $title ,
‘link’ => $link,
‘description’ => $description,
‘pubDate’ => $pubDate);
}

function BuildRSS() {
$s = “<?xml version=\”1.0\” encoding=\”UTF-8\” ?>\n<rss version=\”2.0\”> \n”;
// start channel
$s .= “<channel>\n”;
$s .= “<title>$this->channel_title</title>\n”;
$s .= “<link>$this->channel_link</link>\n”;
$s .= “<description>$this->channel_description</description>\n”;
$s .= “<language>$this->language</language>\n”;
if (!empty($this->copyright)) {
$s .= “<copyright>$this->copyright</copyright>\n”;
}
if (!empty($this->webMaster)) {
$s .= “<webMaster>$this->webMaster</webMaster>\n”;
}
if (!empty($this->pubDate)) {
$s .= “<pubDate>$this->pubDate</pubDate>\n”;
}
if (!empty($this->generator)) {
$s .= “<generator>$this->generator</generator>\n”;
}

// start items
if (count($this->items)>=1){
foreach ($this->items as $key=>$value){
$s .= “<item>\n”;
$s .= “<title>”.$value[’titile’].”</title>\n”;
$s .= “<link>”.$value[’link’].”</link>\n”;
$s .= “<description>”.$value[’description’].”</description>\n”;
$s .= “<pubDate>”.$value[’pubDate’].”</pubDate>\n”;
$s .= “<guid isPermaLink=\”true\”>”.$value[’link’].”</guid>”;
$s .= “</item>\n”;
}
}
// close channel
$s .= “</channel>\n</rss>”;
$this->content = $s;
}

function Show() {
if (empty($this->content)) $this->BuildRSS();
header(’Content-type:text/xml’);
echo($this->content);
}

function SaveToFile($fname) {
if (empty($this->content)) $this->BuildRSS();
$handle = fopen($fname, ‘wb’);
if ($handle === false) {
return false;
}else{
fwrite($handle, $this->content);
fclose($handle);
return true;
}
}
}
?>


iasky 2008-04-06
  • 打赏
  • 举报
回复
xml不过是一种格式而已
fxs_2008 2008-04-05
  • 打赏
  • 举报
回复
这象是RSS吧
读出来
一个个echo吧,做个数据量多的话可循环一下!
Unending 2008-04-05
  • 打赏
  • 举报
回复
并且自动生成xml文件那再简单不过:print
至于最新三条数据用排序查询出来不久得了?

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧