You are here:  » Parsing Multiple children for same record using loop


Parsing Multiple children for same record using loop

Submitted by crounauer on Thu, 2006-03-09 14:51 in

Hi David,

I wonder if you could please point me in the right direction once again?

I am parsing records for hotels and am having difficulty creating a loop to get all the information about particular rooms.

For instance one hotel has many rooms, which will all have different pricing according to availability.

I am able to extract the first room details, but not the 2 or 3.

Thanks,
Simon.

Submitted by crounauer on Thu, 2006-03-09 14:54

This is the code I have so far...

require("includes/MagicParser.php");
function myRecordHandler($item)
  {
print "".$item["HOTEL_ROOMS/ROOM/TYPE"]."<br>";
print "".$item["HOTEL_ROOMS/ROOM/SLEEPS"]."<br>";
print "".$item["HOTEL_ROOMS/ROOM/DESCRIPTION"]."<br>";
print "".$item["HOTEL_ROOMS/ROOM/ALTERNATE_DESCRIPTION"]."<br>";
print "".$item["HOTEL_ROOMS/ROOM/RACK_RATE"]."<br>";
    print "".$item["HOTEL_ROOMS/ROOM/LR_RATES"]."<br>"; ##MORE THAN ONE
print "".$item["HOTEL_ROOMS/ROOM/LR_RATES/RATE/DATE"]."<br>";
print "".$item["HOTEL_ROOMS/ROOM/LR_RATES/RATE/PRICE"]."<br>";
  }
  $url = "http://xxxxxxxxxxxxxxxxxxxxx";
  MagicParser_parse($url,"myRecordHandler","xml|HOTEL_SEARCH/HOTEL/");

Submitted by support on Thu, 2006-03-09 15:59

Hi Simon,

I released a new version of MagicParser.php yesterday; which resolves duplicate key names (which is why you can only see one rate) by appending @1,@2 etc.. to the end of the key names.

The updated documentation for MagicParser_parse() is here, so if you download the latest version you should be able to access all rates...