I have a simple xml file that I am parsing, but would like to reverse order the entries.
<?php
$mainURL = $this->url();
print $mainUrl;
function vimeoChannels($record)
{
print '<li>';
print '<i class="icon-bookmark"></i> <a ';
print ' href="';
print URL_PUBLIC;
print 'video/channel/';
print $record["ID"];
print '/">';
print $record["NAME"];
$channelname = $record["NAME"];
print '</a>';
print '</li>';
}
MagicParser_parse("{link saved}","vimeoChannels","xml|CHANNELS/CHANNEL/");
?>
Hi,
The best way to reverse records is to parse the records into an array, reverse the array and then process each array entry using exactly the same record handler function as your existing code. Consider the following example;
<?php
$mainURL = $this->url();
print $mainUrl;
function vimeoChannels($record)
{
print '<li>';
print '<i class="icon-bookmark"></i> <a ';
print ' href="';
print URL_PUBLIC;
print 'video/channel/';
print $record["ID"];
print '/">';
print $record["NAME"];
$channelname = $record["NAME"];
print '</a>';
print '</li>';
}
$records = array();
function myRecordHandler($record)
{
global $records;
$records[] = $record;
}
MagicParser_parse("{link saved}","myRecordHandler","xml|CHANNELS/CHANNEL/");
$records = array_revers($records);
foreach($records as $record)
{
vimeoChannels($record);
}
?>
Hope this helps!
Cheers,
David
--
MagicParser.com