<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Tutorial Blog &#187; xml</title>
	<atom:link href="http://www.thetutorialblog.com/tag/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thetutorialblog.com</link>
	<description></description>
	<lastBuildDate>Tue, 08 Nov 2011 19:21:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<image>
<link>http://www.thetutorialblog.com</link>
<url>http://www.thetutorialblog.com/wp-content/plugins/maxblogpress-favicon/icons/favicon-28.ico</url>
<title>The Tutorial Blog</title>
</image>
		<item>
		<title>Retrieving an RSS Feed in PHP</title>
		<link>http://www.thetutorialblog.com/php/retrieving-an-rss-feed-in-php/</link>
		<comments>http://www.thetutorialblog.com/php/retrieving-an-rss-feed-in-php/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 00:23:38 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Text Tutorials]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[foreach]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=31</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	RSS Feeds are widely used throughout the internet today and on all kinds of websites. From websites like Digg to most blogs. If you want to display an RSS feed on your website its probably easier than you think. For this example I'm going to show you how to display the RSS feed for The [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fphp%2Fretrieving-an-rss-feed-in-php%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fphp%2Fretrieving-an-rss-feed-in-php%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="Retrieving an RSS Feed in PHP" alt=" Retrieving an RSS Feed in PHP" /><br />
			</a>
		</div>
<p><a href="http://en.wikipedia.org/wiki/RSS_(file_format)">RSS Feeds</a> are widely used throughout the internet today and on all kinds of websites. From websites like <a href="http://www.digg.com">Digg</a> to most blogs. If you want to display an RSS feed on your website its probably easier than you think.</p>
<p>For this example I'm going to show you how to display the RSS feed for The Tutorial Blog using <a href="http://www.php.net">PHP</a>.</p>
<p><span id="more-31"></span></p>
<h2>The Code</h2>
<p>The first two lines of code that we write are going to be what retrieve the RSS feed.<br />
<div id="code_div">$file = <a href="http://uk3.php.net/manual/en/function.file-get-contents.php">file_get_contents</a>("http://www.thetutorialblog.com/feed/");<br />
$xml = new <a href="http://uk3.php.net/SimpleXML">SimpleXMLElement</a>($file);</div><br />
Now the next thing we do is use the foreach function so for each item found do something with it<br />
<div id="code_div"><a href="http://uk3.php.net/manual/en/control-structures.foreach.php">foreach</a>($xml-&gt;channel-&gt;item as $feed){<br />
echo $feed-&gt;title.'&lt;br&gt;';<br />
}</div><br />
What are code will do is simply echo the titles of all the items found within the feeds. If you also want to include a link to the feed you can do this by printing to screen <strong>$feed-&gt;link</strong>.</p>
<p>All the code together should look something like this.<br />
<div id="code_div">&lt;?php</p>
<p>$file = file_get_contents("http://www.thetutorialblog.com/feed/");<br />
$xml = new SimpleXMLElement($file);</p>
<p>foreach($xml-&gt;channel-&gt;item as $feed){<br />
echo $feed-&gt;title.'&lt;br&gt;';<br />
}<br />
?&gt;</div></p>
<p>Thanks for taking the time to read this tutorial. I hope you have learned something.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/php/retrieving-an-rss-feed-in-php/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

