代码如下:
index.html
<html>
<head>
< >
function showRSS(str) {
if (str.length==0) {
document.getElementById(\"output\").innerHTML=\"\";
return;
}
if (window. HttpRequest) {
http=new HttpRequest();
}
else
{
http=new ActiveX (\"Microsoft. HTTP\");
}
http. =function() {
if ( http.readyState==4 && http.status==200) {
document.getElementById(\"output\").innerHTML= http.responseText;
}
}
http.open(\"GET\",\"rss.php?q=\"+str,true);
http.send();
}
</ >
</head>
<body>
<p>Please Select an option to get RSS:</p>
<form>
<select =\"showRSS(this.value)\">
<option value=\"\">Select an RSS-feed:</option>
<option value=\"cnn\">CNN</option>
<option value=\"bbc\">BBC News</option>
<option value=\"pc\">PC World</option>
</select>
</form>
<br>
<div id=\"output\">RSS-feeds</div>
</body>
</html>
<##ads_in_article_manong##>
rss.php
<?php
$q=$_GET[\"q\"];
if($q==\"cnn\") {
$ =(\"http://rss.cnn.com/rss/cnn_topstories.rss\");
}
elseif($q==\"bbc\") {
$ =(\"http://newsrss.bbc.co.uk/rss/newsonline_world_edition/americas/rss. \");
}
elseif($q=\"pcw\"){
$ =(\"http://www.pcworld.com/index.rss\");
}
$ Doc = new DOMDocument();
$ Doc->load($ );
$channel=$ Doc->getElementsByTagName(\'channel\')->item(0);
$channel_ = $channel->getElementsByTagName(\' \')->item(0)->childNodes->item(0)->nodeValue;
$channel_ = $channel->getElementsByTagName(\' \')->item(0)->childNodes->item(0)->nodeValue;
$channel_desc = $channel->getElementsByTagName(\'de ion\')->item(0)->childNodes->item(0)->nodeValue;
echo(\"<p><a href=\'\" . $channel_ . \"\'>\" . $channel_ . \"</a>\");
echo(\"<br>\");
echo($channel_desc . \"</p>\");
$x=$ Doc->getElementsByTagName(\'item\');
for ($i=0; $i<=2; $i++) {
$item_ =$x->item($i)->getElementsByTagName(\' \')->item(0)->childNodes->item(0)->nodeValue;
$item_ =$x->item($i)->getElementsByTagName(\' \') ->item(0)->childNodes->item(0)->nodeValue;
$item_desc=$x->item($i)->getElementsByTagName(\'de ion\') ->item(0)->childNodes->item(0)->nodeValue;
echo (\"<p><a href=\'\" . $item_ . \"\'>\" . $item_ . \"</a>\");
echo (\"<br>\");
echo ($item_desc . \"</p>\");
}
?> 继续阅读与本文标签相同的文章
上一篇 :
php 文件上传实例
下一篇 :
php mail邮件配置方法
-
新款iphone11已经发布有些日子,这款手机好不好用呢?用数据告诉你
2026-05-14栏目: 教程
-
超进化,时尚玩主的全新一代名爵ZS,起步只要7.98万
2026-05-14栏目: 教程
-
微信 7.0.8 内测新功能,教你如何激活它
2026-05-14栏目: 教程
-
美女机器人刚上市就售罄,除了生孩子,其他什么都能干!
2026-05-14栏目: 教程
-
互联网之光大会的黑科技,总有一款惊艳你!
2026-05-14栏目: 教程
