Accessing the additional dates involves using the @n postfix that Magic Parser adds to each additional date record to resolve sub-records of the same name within the record. The technique is to create a loop that keeps adding @1, @2 etc. to the date field until it is no longer set, and then use that postfix to access the date within each iteration.
Hi Simon,
Accessing the additional dates involves using the @n postfix that Magic Parser adds to each additional date record to resolve sub-records of the same name within the record. The technique is to create a loop that keeps adding @1, @2 etc. to the date field until it is no longer set, and then use that postfix to access the date within each iteration.
Example Link
Here's the source code to the above file to demonstrate what I mean...
<?php
require("MagicParser.php");
function myRecordHandler($record)
{
print "<h2>".$record["HOTEL_NAME"]."</h2>";
$i = 0;
while(1) {
if ($i) $postfix = "@".$i;
$exists = isset($record["LR_RATES/HOTEL_ROOMS/ROOM/RATE".$postfix]);
if (!$exists) break;
print "<li>";
print $record["LR_RATES/HOTEL_ROOMS/ROOM/RATE/FORMATTED_DATE".$postfix];
print " - ";
print $record["LR_RATES/HOTEL_ROOMS/ROOM/RATE/PRICE".$postfix];
print "</li>";
$i++;
}
}
MagicParser_parse("hotel.xml","myRecordHandler","xml|HOTEL_SEARCH/HOTEL/");
?>
Hope this helps!
Cheers,
David.