xml实现rss订阅
来源:互联网 发布:荷兰首相知乎 编辑:程序博客网 时间:2024/05/21 09:03
RSS是一种网页内容联合格式,是XML的一种,所有的RSS文档都遵循XML1.0规范。
具体示例:
<span style="font-family:Microsoft YaHei;font-size:18px;"><?xml version = "1.0" encoding = "utf-8" ?><rss version = "2.0" xmlns:wfw ="http://wellformedweb.org/CommentAPI/"> <channel> <title>标题</title> <link>链接地址</link> <description>描述</description> <language>描述语言</language> <copyright>版本</copyright> <pubdate>时间</pubdate> <item> <title>日志标题</title> <link>日志的url访问地址</link> <author>日志的作者</author> <pubdate>日志的发布时间</pubdate> <description>日志的内容</description> </item> </channel></rss></span>
此时应该链接数据库,输出想要的结果。
Test.php
<span style="font-family:Microsoft YaHei;font-size:18px;"><?PHP include("./conn.php"); class test{ public $title = ''; public $link = ''; public $description= ''; public $items = ''; public $template ='./test.xml'; public $dom = ''; public $rss = ''; public function__construct(){ $this ->dom = new domDocument('1.0','utf-8'); $this ->dom -> load($this -> template); $this ->rss = $this -> dom -> GetElementsByTagName('rss'); } public functioncreateChannel(){ $channel =$this -> dom -> createElement("channel"); $channel-> appendChild($this -> createEle('title',$this -> title)); $channel-> appendChild($this -> createEle('link',$this -> link)); $channel-> appendChild($this -> createEle('description',$this ->description)); $this ->rss -> appendChild($channel); } public functioncreateEle($name,$value){ $element =$this -> dom -> createElement($name); $text = $this-> dom -> createTextNode($value); $element-> appendChild($text); return$element; } protected functionadditem($list){ foreach($listas $goods){ $this-> rss -> appendChild($this-> createitem($goods)); } } public functioncreateitem($arr){ $item = $this-> dom -> createElement("item"); foreach($arras $key => $value){ $item-> appendChild($this -> createEle($key,$value)); } return $item; } public functiondisplay(){ $this ->createChannel(); $this ->additem($this -> items); echo $this-> dom -> savexml(); } } $sql = "select * fromstu"; $rs = mysql_query($sql); while($row =mysql_fetch_assoc($rs)){ $list[] = $row; } $test = new test(); $test -> title = "测试标题"; $test -> link = "测试连接"; $test -> description ="测试内容"; $test -> display(); $test -> items = $list;</span>
0 0
- xml实现rss订阅
- XML--做rss订阅
- RSS订阅的xml格式
- C#操作RSS 实现订阅
- php实现rss订阅功能
- C# 操作RSS实现订阅
- asp.net实现RSS订阅
- asp.net实现RSS订阅
- 通过rome实现RSS订阅
- JavaScript 解析 xml 文件 如 rss订阅
- RSS文章订阅及生成RSS格式的xml
- Rss订阅
- RSS订阅
- RSS订阅
- RSS订阅
- RSS订阅
- RSS订阅
- rss订阅
- 华为机试 地铁换乘问题(最短路径算法)
- cmd命令
- POJ 1451 T9(字典树+bfs)
- iOS之UIImage的三中读取方法
- poj1321(深搜)
- xml实现rss订阅
- 暑假-树状数组-F - Brainman
- 如何添加一个已有项目到GitHub
- hdoj 1379 DNA Sorting【排序】
- Ubuntu14.04安装NVIDIA显卡驱动
- 【华为oj】提取不重复的整数
- ESP定律和堆栈平衡
- 电容标识
- PHP应用API接口实现