Link to home
Start Free TrialLog in
Avatar of lilyyan
lilyyan

asked on

how to display only the most recent five entries of a RSS feed ?

hello

i have a RSS feed xml file ( it's a web link ). i want to display only the top five news in the xml file. if user click the read more button, then this user will be linked to the whole RSS feed file.

i am totally new to RSS. how to achieve this function? some sample code will be very helpful: )

thanks so much for your help!
Avatar of silemone
silemone
Flag of United States of America image

are u using xslt?  you could use the count variable
Avatar of lilyyan
lilyyan

ASKER

i'm using php...
ok..just php...got it...
http://lastrss.oslab.net/lastRSS.phps

>>>> Chnage  $items_limit and try this.


Thanks,
M.Raja
Avatar of lilyyan

ASKER

hi, thanks much for  all replies.

i need some detail instructions....

well, first : i need parse the xml file and be able to display it in a html format. i only need get the news title, date, and the news url link.

second: i only want to display the top 5 news every time.

how to do the above two steps : )) thanks a lot !

Avatar of lilyyan

ASKER

how  to invoke this file: lastRSS.php ( http://lastrss.oslab.net/lastRSS.phps)?
Show us the PHP code you are using to generate the XML file that forms the RSS feed.  Maybe we can help  if we see the RSS generation.

For my own purposes, I use a little CRON job that scans a directory for changes.  When the changes occur, I post a new RSS file.  It would be easy to modify that code to fit your needs, so just show us what you're doing now and I'll have a run at it.

Thanks, ~Ray
Avatar of lilyyan

ASKER

HI, thanks a lot for your reply.

i am trying to use this link: http://lastrss.oslab.net/lastRSS.phps to parse the xml file. but i am wondering how to invoke this file. may you help me check the code? thanks so much.

attach is my rss feed file sample.
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Local News</title>
    <link>http://news.test.com/</link>
    <description>Test News from Test</description>
    <language>en-us</language>
 	  
	  <item>
	 	<pubDate>Wed, 23 Apr 2008 14:53:00 EDT</pubDate> 
 
	 <title>The companies based on  research in Silicon Valley</title>
	<link>http://news.test.com/2008a/Silicon.html</link>
	  <description><![CDATA[The companies launched from research developed have won the opportunity to make formal
 
<p class="FORMAT-BODY">LLC were picked from several businesses.</p>]]></description> 
	   <guid>http://news.test.com/2008a/Silicon.html</guid>
	   </item>
	  
	  <item>
	 	<pubDate>Wed, 23 Apr 2008 10:51:00 EDT</pubDate> 
 
	 <title>Online tool aids in local development</title>
	<link>http://news.test.com/2008a/080423FarnsworthLDM.html</link>
	  <description><![CDATA[Land use and economic development planning takes time and money.
<p class="FORMAT-BODY">LDM is a comprehensive planning tool.</p>]]></description> 
	   <guid>http://news.test.com/2008a/080423FarnsworthLDM.html</guid>
	   </item>
	  
	  <item>
	 	<pubDate>Wed, 23 Apr 2008 09:49:00 EDT</pubDate> 
 
	 <title>environmental issues on alternative energy</title>
	<link>http://news.test.com/2008a/Hydrogen.html</link>
	  <description><![CDATA[Petroleum prices and environmental concerns.
<p class="FORMAT-BODY">Symposium 2008, on April 2.</p>]]></description> 
	   <guid>http://news.test.com/2008a/Hydrogen.html</guid>
	   </item>
 
</channel>
</rss>

Open in new window

Lilyyan: The code posted here is the XML.  What we need to see is the code that generates the XML file.  Please post that code and we can probably help. ~Ray
Avatar of lilyyan

ASKER

sorry. i don't have that code.

i only have the xml file. what i try to implement is to extract the data from the xml. i only  want to display the top five news from the xml file in a html format...

and i'm trying to use the code in this link: http://lastrss.oslab.net/lastRSS.phps
just don't how to invoke the functions in the file. may you please have a check. thanks so much
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial