print object value from XML in PHP : <p>I need to read rss feed and then re-create feeds as it is.<br>
If there is 10 item I just need 3. But I want to define which one. first 3 or last 3 or middle. After this I need to show only 3 item in feed. But feed most as it was previous one. Only my purpose is to split Feed.<br>
Here what I'm using but it's not working.  </p>

<pre><code>&lt;?php
header("Content-Type: application/rss+xml; charset=ISO-8859-1");

echo '&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;rss version="2.0"&gt;';

$url_number = $_GET['u'];
$offset = $_GET['o'];
$limit = $_GET['l'];


$url = 'url_of_the_feed';

$feed = simplexml_load_file($url);

echo "&lt;channel&gt;". (string) $feed-&gt;channel. "&lt;/channel&gt;";

$i = 1;

foreach($feed-&gt;channel-&gt;item as $item){

    if($i &gt;= $offset &amp;&amp; $i &lt;= $limit){
        echo "&lt;item&gt;" . $item . "&lt;/item&gt;";
    }

    if($i == $limit){
        break;
    }

    $i++;

}

echo "&lt;/channel&gt;&lt;/rss&gt;";

?&gt;
</code></pre>

<p>This is not printing anything inside channel and item.</p>
