PHPPEAR provides an RSS Resolution class for you to obtain the relevant information from the RSS feed. Demand download XML_RSS: http://pear.php.net/package/XML_RSSXML_Parserhttp://pear.php.net/package/XML_ParserPEARhttp://pear.p
Php pear provides an RSS Resolution class to help you obtain the relevant information from your RSS feed.
Requirement
Download XML_RSS: http://pear.php.net/package/XML_RSS
XML_Parser http://pear.php.net/package/XML_Parser
PEAR http://pear.php.net/package/PEAR
For the relationship between specific paths, just debug it a little. After I decompress the compressed package, I will extract the RSS in it. php, Parser. php, PEAR. php is put in the same directory, and then RSS. in php
Require_once 'XML/Parser. php ';
Change
Require_once 'XML/Parser. php ';
You can use it.
RSS version
After a simple test, I found that it worked well on the three major RSS versions mentioned above, and there was no problem. It indicates that it supports at least the main RSS versions (0.91, 1.0, 2.0)
Example
Using XML_RSS to analyze RSS is particularly simple. First include the class file:
Require "RSS. php ";
Create a class instance based on the resource address:
$ Url = "test. rss ";
$ R = & new XML_RSS ($ url );
Of course, the $ url here can also be a remote path. you need to set allow_url_fopen in php. ini to On, because it is set by default, so you do not need to change it.
Perform analysis:
$ R-> parse ();
The following information can be obtained:
$ R-> getStructure () returns an array containing all the structure information of the RSS file.
$ R-> getChannelInfo () returns an array containing the overview information of the current RSS channel, such as title, link, and description.
$ R-> getItems () returns a two-dimensional array containing all the item information in the RSS file. Each group contains the title, link, description, date, and so on.
$ R-> getImages () returns a two-dimensional array that contains all the image information in the RSS file. each group of information contains the title, link, url, and so on.
$ R-> getTextinputs () returns a two-group array that contains information about all input regions of the RSS file. Each group contains information such as title, link, description, and name.
How to print the content list based on an address
$ Url = "http://www.php100.com/data/rss/37.xml ";
$ R = & new XML_RSS ($ url );
$ R-> parse ();
$ Items = $ r-> getItems ()
Foreach ($ items as $ k => $ item)
{
// $ Item contains link: Content link; title: content title; description: content description; pubdate: content table publication date, depending on the site, not necessarily provided
?>
"Target =" _ blank ">
}
?>