Forum Moderators: open
I have an RSS feed coming from Example.com which I am displaying on my blog. The problem is that I can't understand how to parse this information into the format I want to use. A portion of the feed that I am receiving from Example.com in RSS 2.0:
<item>
<title>Brian's Birthday</title>
-
<link>
....blah blah blah
</link>
-
<description>
....blah blah blah
</description>
<pubDate>Tue, 15 Aug 2006 05:00:00 GMT</pubDate>
-
I am using a magpie RSS reader to try and parse and display a portion of this information on my blog. The code inside of my ExpressionEngine/PMachine magpie RSS reader looks like this:
{exp:magpie url="http://www.example.com/rss/feed.asp?e=16591&k=efbc03446478901b90f5ea032f2e4c99" limit="2" refresh="720"}
<ul>
{items}
<li>{title}{description}</li>
{/items}
</ul>
{/exp:magpie}
Whew - What I am trying to do is simply have the <title> and the <pubDate> WITHOUT THE TIME CODE displayed.
IOW, like this: Brian's Birthday Tue, 15 Aug 2006
I cannot figure out how to do this. How can I parse out the <pubDate> and display just the the portion of the <pubdate> shown above i.e. without the time code?
Am I totally off-track? As I said, I am new to RSS and can't seem to find an answer after spending several hours searching various forums...
Please advise!
[edited by: werty at 2:11 pm (utc) on Dec. 15, 2005]
[edit reason] Changed urls to Example.com. Please see TOS #13 [/edit]
A section of a rss feed with current weather conditions,
- <item>
- <title>
Overcast and 21 degrees F at Location, State
</title>
<link> http://example.gov/ </link>
- <description>
Winds are Calm. Last Updated on Dec 15, 12:55 pm PST.
</description>
</item>
Here is how I parse it,
require_once( 'rss_fetch.inc' );
// Include magpie$rss = fetch_rss('http://example.com/current_weather_conditions.rss');
// Grab RSS feed and store into variable$item = $rss->items[0];
// Split and store rss into the $item array$title = $item[ 'title' ];
// Grab and store the title section from the RSS feedpreg_match( '/[0-9]+/', $title, $matches );
// Parse the title text for numbers and store them in the $matches array$conditions = explode( "and", $item[ 'title' ], 2 );
// Split apart title grabbing and storing text before the word "and"$conditions = trim( $conditions[0] );
// Trim off any whitespacs$weather = $matches[0] .'° F and '. strtolower( $cond );
// Put it all togetherecho 'Weather: '. $weather;
displays,
Weather: 21° F and overcast