Given this fragment of a larger SOAP response:
<Calendar>
<CalendarDay Date="2013-10-01" xmlns="http://webservices.micros.com/og/4.3/Availability/">
<Occupancy>
<RoomTypeInventory roomTypeCode="2BS" totalRooms="26" overBookingLimit="0" soldDeductible="0" soldNonDeductible="0" totalAvailableRooms="26" xmlns="http://webservices.micros.com/og/4.3/HotelCommon/"/>
<RoomTypeInventory roomTypeCode="3BS" totalRooms="4" overBookingLimit="0" soldDeductible="0" soldNonDeductible="0" totalAvailableRooms="4" xmlns="http://webservices.micros.com/og/4.3/HotelCommon/"/>
<RoomTypeInventory roomTypeCode="BSV" totalRooms="3" overBookingLimit="0" soldDeductible="0" soldNonDeductible="0" totalAvailableRooms="3" xmlns="http://webservices.micros.com/og/4.3/HotelCommon/"/>
<RoomTypeInventory roomTypeCode="CHV" totalRooms="1" overBookingLimit="0" soldDeductible="0" soldNonDeductible="0" totalAvailableRooms="1" xmlns="http://webservices.micros.com/og/4.3/HotelCommon/"/>
<RoomTypeInventory roomTypeCode="D3B" totalRooms="6" overBookingLimit="0" soldDeductible="0" soldNonDeductible="0" totalAvailableRooms="6" xmlns="http://webservices.micros.com/og/4.3/HotelCommon/"/>
<RoomTypeInventory roomTypeCode="DLDB" totalRooms="86" overBookingLimit="0" soldDeductible="0" soldNonDeductible="0" totalAvailableRooms="86" xmlns="http://webservices.micros.com/og/4.3/HotelCommon/"/>
<RoomTypeInventory roomTypeCode="DLDC" totalRooms="81" overBookingLimit="0" soldDeductible="0" soldNonDeductible="0" totalAvailableRooms="81" xmlns="http://webservices.micros.com/og/4.3/HotelCommon/"/>
<RoomTypeInventory roomTypeCode="DLKB" totalRooms="123" overBookingLimit="0" soldDeductible="0" soldNonDeductible="0" totalAvailableRooms="123" xmlns="http://webservices.micros.com/og/4.3/HotelCommon/"/>
<RoomTypeInventory roomTypeCode="DLKC" totalRooms="117" overBookingLimit="0" soldDeductible="0" soldNonDeductible="0" totalAvailableRooms="117" xmlns="http://webservices.micros.com/og/4.3/HotelCommon/"/>
<RoomTypeInventory roomTypeCode="GDDB" totalRooms="4" overBookingLimit="0" soldDeductible="0" soldNonDeductible="0" totalAvailableRooms="4" xmlns="http://webservices.micros.com/og/4.3/HotelCommon/"/>
<RoomTypeInventory roomTypeCode="GDDC" totalRooms="17" overBookingLimit="0" soldDeductible="0" soldNonDeductible="0" totalAvailableRooms="17" xmlns="http://webservices.micros.com/og/4.3/HotelCommon/"/>
<RoomTypeInventory roomTypeCode="GDKB" totalRooms="20" overBookingLimit="0" soldDeductible="0" soldNonDeductible="0" totalAvailableRooms="20" xmlns="http://webservices.micros.com/og/4.3/HotelCommon/"/>
<RoomTypeInventory roomTypeCode="GMS" totalRooms="3" overBookingLimit="0" soldDeductible="0" soldNonDeductible="0" totalAvailableRooms="3" xmlns="http://webservices.micros.com/og/4.3/HotelCommon/"/>
</Occupancy>
</CalendarDay>
<CalendarDay Date="2013-10-02" xmlns="http://webservices.micros.com/og/4.3/Availability/">
...
</CalendarDay>
</Calendar>
I need the Date attribute of each CalendarDay, then an array of RoomTypeInventory elements for each day. All namespaces from the soap Envelope have been registered.
Here's the gist of my code ('a' is a previously registered default namespace):
$CalendarDays = $responseXML->xpath('//a:CalendarDay');
foreach($CalendarDays as $CalendarDay){
$CalendarDate = ($CalendarDay->attributes()->Date);
echo $CalendarDate . " ";
$CalendarDay->registerXPathNamespace('x', 'http://webservices.micros.com/og/4.3/Availability/');
$RoomTypeInventory = $CalendarDay->xpath('//x:RoomTypeInventory');
}
$responseXML = simplexml_load_file('FetchAvailablePackages60Days.resp.xml');
I registered the namespace 'x' because it was the default namespace declared with CalendarDay.
$CalendarDay->attributes()->Date has the correct value. But $RoomTypeInventory is empty.
I've also tried
$RoomTypeInventory = $CalendarDay->xpath('x:Occupancy/x:RoomTypeInventory');
which also fails. But
$Occupancy = $CalendarDay->xpath('x:Occupancy');
returns an appropriate value, so I assume the namespacing is correct.
What am I doing wrong?