\n<?php\n $q=$_GET[\"q\"]; \n if($q==\"cnn\") {\n $xml=(\"http:\/\/rss.cnn.com\/rss\/cnn_topstories.rss\");\n } \n elseif($q==\"bbc\") {\n $xml=(\"http:\/\/newsrss.bbc.co.uk\/rss\/newsonline_world_edition\/americas\/rss.xml\");\n } \n elseif($q=\"pcw\"){\n $xml=(\"http:\/\/www.pcworld.com\/index.rss\");\n }\n $xmlDoc = new DOMDocument();\n $xmlDoc->load($xml); \n $channel=$xmlDoc->getElementsByTagName('channel')->item(0);\n $channel_title = $channel->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;\n $channel_link = $channel->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;\n $channel_desc = $channel->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue;\n echo(\"\" . $channel_title . \"<\/a>\");\n echo(\"
\");\n echo($channel_desc . \"<\/p>\");\n $x=$xmlDoc->getElementsByTagName('item');\n for ($i=0; $i<=2; $i++) {\n $item_title=$x->item($i)->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;\n $item_link=$x->item($i)->getElementsByTagName('link') ->item(0)->childNodes->item(0)->nodeValue;\n $item_desc=$x->item($i)->getElementsByTagName('description') ->item(0)->childNodes->item(0)->nodeValue;\n echo (\"\" . $item_title . \"<\/a>\");\n echo (\"
\");\n echo ($item_desc . \"<\/p>\");\n }\n?>\n<\/pre>\n\nThe above is the entire content of this article. I hope it will be helpful to everyone in learning PHP programming. <\/p>\n\n\n\n\n
Articles you may be interested in: <\/h4>\n\n- Code to read RSS feed with PHP<\/li>\n
- PHP regular expression analysis RSS<\/li>\n
- PHP calls Twitter’s RSS Implementation code<\/li>\n
- Code example of how to implement asynchronous file upload through Ajax in php<\/li>\n
- Simple example code of php XMLWriter class (RSS output)<\/li>\n
- Using ThinkPHP’s built-in ThinkAjax implementation Implementation method of asynchronous transmission technology <\/li>\n
- PHP Ajax asynchronous communication to implement user name and email verification whether registered (2 methods to implement) <\/li>\n
- Ajax asynchronous transmission and PHP interaction example <\/li>\n
- PHP curl grabs AJAX asynchronous content example<\/li>\n
- php method to generate RSS subscription<\/li>\n<\/ul>\n
<\/p>\n
\nhttp:\/\/www.bkjia.com\/PHPjc\/1117074.html<\/span>www.bkjia.com<\/span>true<\/span>http: \/\/www.bkjia.com\/PHPjc\/1117074.html<\/span>TechArticle<\/span>php ajax reads RSS document data asynchronously. RSS (Really Simple Syndication) is a way to describe and synchronize website content. format, is the most widely used XML application. RSS builds a platform for rapid information dissemination...<\/span>\n<\/div>\n