Home > Backend Development > PHP Tutorial > PHP uses RSS to subscribe to articles elsewhere_PHP tutorial

PHP uses RSS to subscribe to articles elsewhere_PHP tutorial

WBOY
Release: 2016-07-22 09:02:53
Original
1237 people have browsed it

This article is a continuation of the previous article on using PHP to operate XML files. RSS is a form based on XML. Its specific specifications are as follows (we look at the format of the intercepted Sina RSS subscription channel):

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





<br> <![CDATA[International News-Sina News]]> <br>

<br> <![CDATA[News Center-International News]]> <br>
http://news.sina.com.cn/world
/tech/UploadPic/2012-12/20121222153257335.gif




http://news.sina.com.cn/491/2008/0827/1.html
zh-cn
WWW.SINA.COM.CN
5



Sat, 22 Dec 2012 05:32:05 GMT




<br> <![CDATA[111 countries support the moratorium on the use of the death penalty, while 41 countries including China, the United States and North Korea oppose]]> <br>
http://go.rss.sina.com.cn/redirect.php?url=http://news.sina.com.cn/w/2012-12-22/120825871683.shtml WWW.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



While the vote is not legally binding, human rights activists say the biennial vote sends a strong signal to countries that still retain the death penalty in dwindling numbers... ]]>




What does the specific specification information mean? We can easily know according to the content of the tag. Next, we write an rss.php to read this xml and obtain the above article:




XML


$dom = simplexml_load_file("http://rss.sina.com.cn/news/world/focus15.xml");
//var_dump($dom);
?>

The example of RSS





Pay attention to this function: simplexml_load_file(); it can read both local xml files and xml on the network.

Run result:

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/371834.htmlTechArticle This article is a continuation of the previous article on using PHP to operate XML files. RSS is a form based on XML. Its specific specifications are as follows (we look at the format of the intercepted Sina RSS subscription channel): Input:...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template