PHP parsing rss method, PHP parsing RSS method
This article explains how PHP parses RSS. Share to everyone for your reference. Specific as follows:
1. The PHP code is as follows:
Copy CodeThe code is as follows: <?php
Require "xml/rss.php";
$rss = new Xml_rss ("Http://php.net/news.rss");
$rss->parse ();
foreach ($rss->getitems () as $item) {
Print_r ($item);
}
?>
2. The rss.php code is as follows:
Copy CodeThe code is as follows: <?php
$database = "Nameofthedatabase";
$dbconnect = Mysql_pconnect (localhost, dbuser, dbpassword);
mysql_select_db ($database, $dbconnect);
$query = "Select link, headline, description from ' headlines ' limit 15";
$result = mysql_query ($query, $dbconnect);
while ($line = Mysql_fetch_assoc ($result))
{
$return [] = $line;
}
$now = Date ("D, D M Y h:i:s T");
$output = "<?xml version=\" 1.0\ "?>
Our Demo RSS
http://www.tracypeterson.com/RSS/RSS.php
A Test RSS
En-US
$now
$now
Http://someurl.com
You@youremail.com
You@youremail.com
";
foreach ($return as $line)
{
$output. = " ". Htmlentities ($line [' headline '])."
". Htmlentities ($line [' link '])."
". Htmlentities (Strip_tags ($line [' description '])."
";
}
$output. = " ";
Header ("Content-type:application/rss+xml");
Echo $output;
?>
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/963850.html www.bkjia.com true http://www.bkjia.com/PHPjc/963850.html techarticle PHP Parsing rss method , PHP parsing RSS method In this paper, we describe the method of PHP parsing RSS. Share to everyone for your reference. Specific as follows: 1. The PHP code is as follows: Copy code code as follows ...