Webmaster Forum

Ezilon Directory   Sell Your Website   V7N Directory
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Reply
 
LinkBack Thread Tools Display Modes
Old 02-25-2005, 04:12 AM   #1 (permalink)
Inactive
 
I, Brian's Avatar
 
Join Date: 10-26-03
Posts: 2,466
iTrader: 0 / 0%
Latest Blog:
None

I, Brian is liked by somebodyI, Brian is liked by somebodyI, Brian is liked by somebodyI, Brian is liked by somebodyI, Brian is liked by somebody
Publishing RSS description with PHP

I'm currently using a script very successfully to publish headlines on a page of my site: http://www.platinax.co.uk/news/extra/

However, I'd like to be able to publish the feed descriptions under the linked headlines.

How could I please modify the following code to publish descriptions as well?


Code:
<?php $xmlfile = file_get_contents ("http://news.bbc.co.uk/rss/newsonline_uk_edition/business/rss091.xml"); if (empty($xmlfile)) die("failed to connect to xml feed"); preg_match_all("|<item>(.*)</item>|sU", $xmlfile, $items); $itemlist = array(); foreach ($items[1] as $key => $item) { preg_match("|<title>(.*)</title>|s", $item, $title); preg_match("|<link>(.*)</link>|s", $item, $link); $itemlist[$key]['title'] = $title[1]; $itemlist[$key]['link'] = $link[1]; } // Display all article titles, linking them to the actual story foreach ($itemlist as $item) { echo '<a href="' . $item['link'] . '">' . $item['title'] . '</a><br>'; } $xmlfile = ""; // empty out the xmlfeed variable so that you can test the next one. ?>
I presume the modification would be fairly simple?

By the way - many thanks in advance for reading this.
I, Brian is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 02-25-2005, 02:49 PM   #2 (permalink)
v7n Mentor
 
hatchet's Avatar
 
Join Date: 10-11-03
Posts: 1,148
iTrader: 0 / 0%
Latest Blog:
None

hatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nice
Try this
Code:
foreach ($items[1] as $key => $item) { preg_match("|<title>(.*)</title>|s", $item, $title); preg_match("|<link>(.*)</link>|s", $item, $link); preg-match("|<description>(.*)</description>|s", $item, $description); $itemlist[$key]['title'] = $title[1]; $itemlist[$key]['link'] = $link[1]; $itemlist[$key]['description'] = $description[1]; }
Then in your echo statement use $item['description'] to place the description.
hatchet is offline  
Add Post to del.icio.us
Reply With Quote
Old 02-25-2005, 02:52 PM   #3 (permalink)
v7n Mentor
 
hatchet's Avatar
 
Join Date: 10-11-03
Posts: 1,148
iTrader: 0 / 0%
Latest Blog:
None

hatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nicehatchet is just really nice
I guess I'll just finish it off

Code:
echo '<a href="' . $item['link'] . '">' . $item['title'] . '</a><br>' . $item['description'] . '<br>';
hatchet is offline  
Add Post to del.icio.us
Reply With Quote
Old 02-26-2005, 03:23 AM   #4 (permalink)
Inactive
 
I, Brian's Avatar
 
Join Date: 10-26-03
Posts: 2,466
iTrader: 0 / 0%
Latest Blog:
None

I, Brian is liked by somebodyI, Brian is liked by somebodyI, Brian is liked by somebodyI, Brian is liked by somebodyI, Brian is liked by somebody
Great hatchet.
I, Brian is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Photoshop Template Publishing? babs Web Design Lobby 5 07-15-2007 10:38 AM
Frontpage crashes when publishing - Error 425. chrisnrach17 Web Design Lobby 1 10-20-2003 09:24 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 11:01 AM.
© Copyright 2008 V7 Inc


Search Engine Optimization by vBSEO 3.1.0 ©2007, Crawlability, Inc.