PHP Beginner's AJAX Reader
First we create two php files
head.php code is as follows:
php中文网(php.cn)
RSS-feed 数据列表...
Next we create another php file, the code is as follows:
load($xml); // 从 "" 中读取元素 $channel=$xmlDoc->getElementsByTagName('channel')->item(0); $channel_title = $channel->getElementsByTagName('title') ->item(0)->childNodes->item(0)->nodeValue; $channel_link = $channel->getElementsByTagName('link') ->item(0)->childNodes->item(0)->nodeValue; $channel_desc = $channel->getElementsByTagName('description') ->item(0)->childNodes->item(0)->nodeValue; // 输出 " " 中的元素 echo(" " . $channel_title . ""); echo("
"); // 输出 "
"); echo($channel_desc . "- " 中的元素 $x=$xmlDoc->getElementsByTagName('item'); for ($i=0; $i<=1; $i++) { $item_title=$x->item($i)->getElementsByTagName('title') ->item(0)->childNodes->item(0)->nodeValue; $item_link=$x->item($i)->getElementsByTagName('link') ->item(0)->childNodes->item(0)->nodeValue; $item_desc=$x->item($i)->getElementsByTagName('description') ->item(0)->childNodes->item(0)->nodeValue; echo ("
" . $item_title . ""); echo ("
"); } ?>
"); echo ($item_desc . "
Continue Next we are going to create a demo.xml file, the code is as follows:
php教程 //m.sbmmt.com学的不仅技术,更新梦想!! RSS 教程 //m.sbmmt.com/rss/rss-tutorial.html通过使用 RSS,您可以有选择地浏览您感兴趣的以及与您的工作相关的新闻�?/description> XML 教程 //m.sbmmt.com/xml/xml-tutorial.htmlXML 指可扩展标记语言(eXtensible Markup Language)