Hi guys, posted a few days ago about doing this with SimpleXML. Didnt quite work out as planned so I have gone back to XPath. Basic XML structure is like so
Code:
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP:Body>
      <hotel:HotelSearchAvailabilityRsp TraceId="test" ResponseTime="28972" xmlns:hotel="..." xmlns:common_v26_0="...">
         <hotel:HotelSearchResult>
            <common_v26_0:VendorLocation VendorCode="MU" VendorLocationID="LONBR" />
            <hotel:HotelProperty HotelChain="MU" HotelCode="BR" HotelLocation="LR" Name="MILLENNIUM" Availability="Available">
               <hotel:PropertyAddress>
                  <hotel:Address>44 SQUARE</hotel:Address>
                  <hotel:Address>ENGLAND</hotel:Address>
               </hotel:PropertyAddress>
               <common_v26_0:PhoneNumber Type="Hotel" Number="029"/>              
            </hotel:HotelProperty>
            <hotel:RateInfo ApproximateMinimumAmount="GBP330.00" ApproximateMaximumAmount="GBP610.00"/>
         </hotel:HotelSearchResult>
      </hotel:HotelSearchAvailabilityRsp>
   </SOAP:Body>
</SOAP:Envelope>
Thats one HotelSearchResult of what may be many. I need to get the hotel name, availability and price. The first two are in the HotelProperty block, the price is in the RateInfo block.

What I have tried to do is get each search result, then perform two loops inside of this. One for the HotelProperty data I need and the other for the RateInfo. This is what I have so far

Code:
    $dom = new DOMDocument('1.0', 'UTF-8');
    $dom->loadXML($serverResponse);
    $xpath = new DOMXPath($dom);

    $xpath->registerNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/');
    $xpath->registerNamespace('hotel', '...');
    $xml_resp = $xpath->evaluate('//hotel:HotelSearchAvailabilityRsp/hotel:HotelSearchResult');

    printf( "<table class='test'>");
    printf ('<tr>');
    printf("<th>Hotel Name</th>");
    printf("<th>Availability</th>");
    printf("<th>Price</th>");
    printf ('</tr>');
    foreach ($xml_resp AS $available)
    {
        $xml_resp2 = $xpath->evaluate('//hotel:HotelSearchAvailabilityRsp/hotel:HotelSearchResult/hotel:HotelProperty');
        foreach ($xml_resp2 AS $available2)
        {
            printf ('<tr>');
            printf("<td>%s  </td>" . PHP_EOL, $available2->getAttribute('Name'));
            printf("<td>%s  </td>" . PHP_EOL, $available2->getAttribute('Availability'));
            printf ('</tr>');
        }

        $xml_resp3 = $xpath->evaluate('//hotel:HotelSearchAvailabilityRsp/hotel:HotelSearchResult/hotel:RateInfo');
        foreach ($xml_resp3 AS $available3)
        {
            printf ('<tr>');
            printf("<td>%s  </td>" . PHP_EOL, $available3->getAttribute('ApproximateMinimumAmount'));
            printf ('</tr>');
        }
    }
    printf( "</table>");
I am back at my original problem now though. I can get the Name and Availability to display, but I can get the ApproximateMinimumAmount.

How would I go about getting this to display for each search result?

Thanks