PHP uses RSS to subscribe to other articles

Source: Internet
Author: User
PHP uses RSS to subscribe to other articles this article is next to using PHP to operate XML files. RSS is a form based on XML. its specific specifications are as follows (we can see in the format of the intercepted Sina RSS subscription channel & #26684;): Input: rss.sina.com. cnnewsworldfocus15.xml & nbsp; view the page source code to see the RSS structure: & lt ;? Xml PHP uses RSS to subscribe to articles elsewhere

This article is followed by the XML file operations using PHP. RSS is a form based on XML. its specific specifications are as follows (we can refer to the format of the Sina RSS subscription channel intercepted ):

Enter: http://rss.sina.com.cn/news/world/focus15.xml view page source code to see the RSS structure:

 
 
 
  
   <! [CDATA [international news-Sina news]>
   
   <! [CDATA [News Center-International News]>
   Http://news.sina.com.cn/world </link>
   
    
Http://www.sinaimg.cn/home/deco/2009/0330/logo_home_news.gif </url>
    国际新闻-焦点新闻
    
    Http://news.sina.com.cn/491/2008/0827/1.html </link>
    
     
Zh-cn
    
    
     
WWW. SINA. COM. CN
    
    
     
5
    
    Copyright 1996 - 2012 SINA Inc. All Rights Reserved
    
    
     
Sat, 22 Dec 2012 05:32:05 GMT
    
    
    
    
     <! [CDATA [111 countries support the suspension of the use of the death penalty. China, the United States, and other 41 countries oppose it]>
     Http://go.rss.sina.com.cn/redirect.php? Url = http://news.sina.com.cn/w/2012-12-22/120825871683.shtmlWWW. SINA. COM. CN
     
      
Http://go.rss.sina.com.cn/redirect.php? Url = http://news.sina.com.cn/w/2012-12-22/120825871683.shtml
     
     国际新闻-焦点新闻
     
     
      
Sat, 22 Dec 2012 04:08:09 GMT
     
     
       【法新社联合国12月20日电】周四,在联大讨论人权问题的主旨会议上,有创纪录的111个国家投票支持暂缓使用死刑。  虽然这次投票在法律上不具备约束力,但是人权活动分子说,每两年举行一次的表决,是向那些依然保留死刑的国家发出的强烈信号,这些数量在逐步减少的国家....
     
      
   
  
 

What is the meaning of the specific specification information? according to the tag content, we can easily know. below we will write an rss. php file to read the xml file and obtain the above article:

            XML      
  The example of RSS 
 
 
    channel->item as $item) { print("
  • "); print("link'>"); print($item->title); print(""); print("
  • "); }?>

Note this function: simplexml_load_file (); it can read both the local xml file and the xml on the network.

Running result:

OK, That's all... Tiandao reward !!

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.