Nested SimpleXML

I’m having trouble grabbing this element, I’ve tried a variety of ways.
I’m trying to grab the unitCost value.

** I Solved it, how embarassing **
I was missing this array… LOL
$xml->accommodationItem[0]->availabilityInfo[0]->unitCost->value;

echo $xml->accommodationItem[0]->name; // Works

echo $xml->accommodationItem[0]->unitCost->value; // nothing

SimpleXMLElement Object
(
    [SearchResponse] => SimpleXMLElement Object
        (
            [accommodationItem] => Array
                (
                    [0] => SimpleXMLElement Object
                        (
                            [name] => Test
                            [max] => 4
                            [availabilityInfo] => Array
                                (
                                    [0] => SimpleXMLElement Object
                                        (
                                            [checkIn] => 11/06/2010
                                            [checkOut] => 11/13/2010
                                            [unitCost] => SimpleXMLElement Object
                                                (
                                                    [value] => 350.00
                                                    [currency] => USD
                                                )
                                        )

You could also get rid of the [0] since SimpleXML can magically handle retrieving the first element when there are multiple ones.

That could be useful maybe another day, Im using a foreach loop I just copied a snippet. :smiley: :smiley: