创建rss xml [英] create rss xml

查看:111
本文介绍了创建rss xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建xml提要,因为在网络数据提取后我的数据库中有数据准备好了b $ b。但是,这行有错误:


< xml version =" 1.0" encoding =" ISO-8859-1">


我无法解决这个问题。


< html>

< head>

< title> MMU RSS FEED< / title>

< / head>

< ; body>


header(" Content-type:application / xml");

< xml version =" 1.0" encoding =" ISO-8859-1"


< rss version =" 2.0">

< channel>

< title> MMU RSS FEED今天:<?php echo date(" D,dMY H:i:s")?>< /

title>

< link> http://bulletin.mmu.edu.my/< / link>

< description> MMU RSS FEED< / description>

< ttl> 60< ttl>


<?php


//连接到数据库

$ db = mysql_connect(" localhost"," root","")或die(mysql_error());

mysql_select_db(" bulletin",$ db )或死(mysql_error());


$ day = date(" Yn-j");


//选择查询

$ sql =" SELECT * FROM`bul_data` WHERE`DATE` LIKE''{$ day}%''ORDER by

`DEPARTMENT`";

echo" sql ="。$ sql;


$ res = mysql_query($ sql)或die(mysql_error());


if(mysql_ num_rows($ res)> 0)

{


while($ row = mysql_fetch_assoc($ res))

{

$ date = $ row [''DATE''];

$ title = $ row [''TITLE''];

$ department = $ row [''DEPARTMENT''];

$ link = $ row [''LINK''];


//输出到浏览器


echo"< item>" ;;

echo"< title> $ title< / title>" ;;

echo"< category> $ department< / category>" ;;

echo"< link>< a href = \" $ link \" ;> $ link< / a>< / link>" ;;

echo"< / item>" ;;

}


echo"< / table>" ;;


}


?>


< / channel>

< / rss>

< / body>

< / html>

I''m currently working on creating the xml feed since I had data ready
in my database after web data extraction. However, it has errors for
this line:

<xml version="1.0" encoding="ISO-8859-1">

I was unable to solve this.

<html>
<head>
<title>MMU RSS FEED</title>
</head>
<body>

header("Content-type: application/xml");
<xml version="1.0" encoding="ISO-8859-1">

<rss version ="2.0">
<channel>
<title>MMU RSS FEED Today: <?php echo date("D, d-M-Y H:i:s")?></
title>
<link>http://bulletin.mmu.edu.my/</link>
<description>MMU RSS FEED</description>
<ttl>60<ttl>

<?php

//connect to database
$db = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("bulletin", $db) or die(mysql_error());

$day = date("Y-n-j");

//select queries
$sql = "SELECT * FROM `bul_data` WHERE `DATE` LIKE ''{$day}%'' ORDER by
`DEPARTMENT`";
echo "sql=".$sql;

$res = mysql_query($sql) or die(mysql_error());

if(mysql_num_rows($res)>0)
{

while($row=mysql_fetch_assoc($res))
{
$date = $row[''DATE''];
$title = $row[''TITLE''];
$department = $row[''DEPARTMENT''];
$link = $row[''LINK''];

//output to browser

echo "<item>";
echo "<title>$title</title>";
echo "<category>$department</category>";
echo "<link><a href=\"$link\">$link</a></link>";
echo "</item>";
}

echo "</table>";

}

?>

</channel>
</rss>
</body>
</html>

推荐答案

db = mysql_connect(" localhost"," roo t","")或die(mysql_error());

mysql_select_db(" bulletin",
db = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("bulletin",


db)或die(mysql_error() );

db) or die(mysql_error());


day = date(" Yn-j");


//选择查询
day = date("Y-n-j");

//select queries


这篇关于创建rss xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆