title: How to loop and display (n) feeds using simpleXML and position()
body: <p>I am using simpleXML and I want to loop though the feed to only display 5 shows using the position() method, but have no joy in getting it to work</p>
  
  <pre><code>foreach($xml-&gt;sortedXPath('TV[position() &lt; 5 and ProgrammeName="MTV"]', 'TransmissionDate', SORT_DESC) as $i =&gt; $item)
  {
  
      print "&lt;a href='?v=".$item-&gt;ID."&amp;a=false' class='link'&gt;\n";
      print "\t&lt;span class=\"text\"&gt;" .trunc($item-&gt;ShortSynopsis,25, " "). "&lt;/span&gt;\n";
      print "\t&lt;/a&gt;";
  }
  </code></pre>
  
  <p>any suggestions on how I can get this working</p>
  
  <p>this is the XML data I am working with</p>
  
  <p><a href="http://deniselashlley.co.uk/test/data.xml" rel="nofollow noreferrer">http://deniselashlley.co.uk/test/data.xml</a></p>