PHP parsing rss method, PHP parsing rss method _php Tutorial

Source: Internet
Author: User

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

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