[PHP] XML Parser - a little problem

I’m using Eric Pollmann’s PHP-based XML parser, which can be found online at http://eric.pollmann.net/items/2003/9/2003_09_22_xmlparser/XMLParser.php. I’m using this script because it’s one of the few that don’t rely on SOAP, SAX or anything else like that (the webhost doesn’t support them) but at the same time, allows me to also retrieve attributes from the XML nodes.

Anyway, I’m using it on a news XML file that looks like this:


<news>
    <entry date="20061211104345">
      <title>News item title</title>
       <body>
        News item body
       </body>
    </entry>
</news>

and have added the following lines to the end of the PHP script in order to output the news items to the page:


$parser = new XMLParser('xml/news.xml', 'file', 1);
      $tree = $parser->getTree();
  
  arsort( $tree['NEWS']['ENTRY'] );
    
  foreach($tree['NEWS']['ENTRY'] as $newsentry) {
      echo "<h3><a name=\"item" . $newsentry['ATTRIBUTES']['DATE'] . "\" id=\"item" . $newsentry['ATTRIBUTES']['DATE'] . "\"></a>" . $newsentry['TITLE']['VALUE'] . "</h3>
<p>" . $newsentry['BODY']['VALUE'] . "</p>
";
  }

For some reason, this will only show news items if there are more than one present in the XML file and I can’t work out why. The answer is probably staring me in the face, but if someone can point out I’m doing wrong, that would be a BIG help!

Thanks in advance.