Hi guys,

Thanks to prior help on this forum, I have managed to use xpath quite successfully for a number of things. I have now become stuck however. I have the following XML loaded (shortened it).

Code:
<air:LowFareSearchRsp>
    <air:AirPricingSolution Key="HFQDq6elT/ma9JyzOzAyPA==" TotalPrice="GBP2380.25" BasePrice="GBP1800.00" Taxes="GBP580.25">
       <air:AirPricingInfo Key="Hv5kc/V3Tei7hxC49DUV1w==" TotalPrice="GBP2380.25" BasePrice="GBP1800.00" Taxes="GBP580.25">
           <air:BookingInfo BookingCode="L" CabinClass="Economy"/>
           <air:BookingInfo BookingCode="L" CabinClass="Economy"/>
           <air:BookingInfo BookingCode="L" CabinClass="Economy"/>
           <air:BookingInfo BookingCode="L" CabinClass="Economy"/>
           <air:BookingInfo BookingCode="L" CabinClass="Economy"/>
           <air:PassengerType Code="ADT"/>
        </air:AirPricingInfo>
        <air:Connection SegmentIndex="3"/>
    </air:AirPricingSolution>
</air:LowFareSearchRsp>
Now in my XML file which is loaded, there are loads and loads of sections like the above, this is just one I am showing you. So to get the main data from it, I do

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('air', 'http://www.test.com/schema/air_v1');
    $xml_resp = $xpath->evaluate('//air:LowFareSearchRsp/air:AirPricingSolution');

    foreach ($xml_resp AS $available)
    {
        printf("Total Price: %s <br>\r\n" . PHP_EOL, $available->getAttribute('TotalPrice'));
        printf("Base Price: %s <br>\r\n" . PHP_EOL, $available->getAttribute('BasePrice'));
        printf("Taxes: %s <br>\r\n <br>\r\n" . PHP_EOL, $available->getAttribute('Taxes'));
    }
That works fine. Next I wanted to get the BookingInfo BookingCode, so in the above foreach, I added
Code:
    
$sXpath2 = "//air:LowFareSearchRsp/air:AirPricingSolution/air:AirPricingInfo/air:BookingInfo";
$cabinclasslist2 = $xpath->evaluate($sXpath2);

foreach ($cabinclasslist2 AS $available2){
    printf("Booking Code: %s <br>\r\n" . PHP_EOL, $available2->getAttribute('BookingCode'));
}
Now the problem with that is that it prints out every single booking code from every single AirPricingSolution segment. So instead of just printing 5 L's for the above one, it prints out hundreds of letters aswell from all the other ones.

How can I contain the BookingCode's within their own AirPricingSolution block?

Thanks for the help