PHP Ajax asynchronously reads RSS document data,
RSS (Really Simple Syndication) is a format for describing and synchronizing site content and is the most widely used XML application. RSS builds a technology platform for rapid dissemination of information, making everyone a potential provider of information.
The example of this article for everyone to share the PHP Ajax asynchronous reading RSS document data related code, for your reference, the specific content as follows
The code is as follows:
Index.html
Please Select the option to get RSS:
Rss-feeds
rss.php
<?php $q =$_get["Q"]; if ($q = = "CNN") {$xml = ("Http://rss.cnn.com/rss/cnn_topstories.rss");} ElseIf ($q = = "BBC") {$xml = ("Http://newsrss.bbc.co.uk/rss/newsonline_world_edition/americas/rss.xml");} ElseIf ($q = "PCW") {$xml = ("Http://www.pcworld.com/index.rss");} $xmlDoc = new DOMDocument (); $xmlDoc->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 <=2; $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. "
"); }? >
The above is the whole content of this article, I hope that you learn PHP programming help.
Articles you may be interested in:
- Code for reading RSS feeds in PHP
- PHP Regular Expression Analysis RSS
- PHP calls Twitter's RSS implementation code
- code example of how to implement asynchronous file upload via Ajax in PHP
- Simple sample code for PHP XmlWriter Class (RSS output)
- Implementation of asynchronous transmission technology using thinkphp built-in Thinkajax
- Php+ajax asynchronous communication implement user name mailbox verification is registered (2 methods implemented)
- Ajax Asynchronous transfer and PHP implementation interaction example
- PHP Curl fetching Ajax Asynchronous content example
- How PHP generates an RSS feed
http://www.bkjia.com/PHPjc/1117074.html www.bkjia.com true http://www.bkjia.com/PHPjc/1117074.html techarticle PHP Ajax asynchronously reads RSS document data, RSS (Really Simple Syndication) is a format for describing and synchronizing web site content, and is the most widely used XML application. RSS set up the rapid spread of information ...