-1

I don't know why, probably I'm just to stupid but I've been trying to extract stuff from an Expedia API Request for more than 2 hours now. Probably I've been working to long on this site today so that I don't see a simple mistake but anyway I don't find it. The API Request "HotelList" causes this problem for me, getting HotelDetails and extracting data from the return XML output worked just fine and on the first try.

The request/result I get for my request looks like this:

$result = $search->getHotels($dataArray);

--------------------------------------------

RESULT (print_r) LOOKS LIKE THIS

    Array
(
    [current_search] => Array
        (
            [check_in] => 05/08/2013
            [check_out] => 05/13/2013
        )

    [title] => 
    [hotels] => SimpleXMLElement Object
        (
            [customerSessionId] => XXXXXXXXXXXXX
            [numberOfRoomsRequested] => 1
            [moreResultsAvailable] => true
            [cacheKey] => XXXXXXXXXXXXXXXXX
            [cacheLocation] => XXXXXXXXXXXXXX
            [cachedSupplierResponse] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [matchedLocale] => true
                            [matchedCurrency] => true
                            [tpidUsed] => 5102
                            [otherOverheadTime] => 5
                            [candidatePreptime] => 62
                            [supplierResponseTime] => 1950
                            [supplierResponseNum] => 5
                            [supplierRequestNum] => 513
                            [cachedTime] => 0
                            [supplierCacheTolerance] => NOT_SUPPORTED
                        )

                )

            [HotelList] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [activePropertyCount] => 562
                            [size] => 5
                        )

                    [HotelSummary] => Array
                        (
                            [0] => SimpleXMLElement Object
                                (
                                    [@attributes] => Array
                                        (
                                            [ubsScore] => 2147483647
                                            [order] => 0
                                        )

                                    [hotelId] => 126913
                                    [name] => The New Yorker Hotel
                                    [address1] => 481 Eighth Ave.
                                    [city] => New York
                                    [stateProvinceCode] => NY

I've been pretty much trying everything to get the name of this hotel but I can't even extract the check_in return result or anything like that. I was simply trying stuff like this:

echo $result->hotels->HotelList->HotelSummary[0]->name;
echo $result->HotelList->HotelSummary[0]->name;
echo $result->$HotelSummary[0]->name; or
echo $result->current_search->check_in;

and probably like 20 other combinations but there is simply no output at all.

I really hope someone can help me out here.

Best Regards Thomas

hakre
  • 193,403
  • 52
  • 435
  • 836
  • 1
    can you provide a sample of the raw xml its self not print_r formatted would be nice to see your full simplexml request code too. Its probably something simple/obvious but I'm having a lazy brain day today so want to actually run it up myself and test – Dave Mar 05 '13 at 10:37
  • Got it working with Emissary but thank you so much for your effort :) – wordsongoku Mar 05 '13 at 10:49
  • http://php.net/arrays - Possible duplicate of: [Able to see a variable in print_r()'s output, but not sure how to access it in code](http://stackoverflow.com/questions/6322084/able-to-see-a-variable-in-print-rs-output-but-not-sure-how-to-access-it-in-c) – hakre Mar 05 '13 at 10:50
  • You, sir, and Emissary are my HEROES. Three damn hours of my life that I couldn't figure out why in the WORLD I could get zero output. Out of complete desperation, I searched for SimpleXMLObject and HotelList and stumbled on this. How incredibly frustrating and FINALLY solved... – Cyprus106 Jan 19 '14 at 03:22

1 Answers1

2

it looks like: $result['hotels']->HotelList->HotelSummary[0]->name; but obv. untested.

Emissary
  • 9,954
  • 8
  • 54
  • 65
  • Thank you so much Emissary I've just not seen that but it works like a charm now!! :) and, of course, thank you Dave for your effort. – wordsongoku Mar 05 '13 at 10:47