PHP Ajax Asynchronous read RSS document data, _php tutorial

Source: Internet
Author: User
Tags learn php learn php programming php regular expression

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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.