1

使用下面的示例,我应该如何解析“HotelRef”的“HotelCode”属性?

<OTA_HotelAvailRQ Version="1.0" TimeStamp="2005-08-01T09:30:47+02:00" EchoToken="fb57388d" AvailRatesOnly="true" xmlns="http://www.opentravel.org/OTA/2003/05">
     <AvailRequestSegments>
        <AvailRequestSegment AvailReqType="Room">
           <HotelSearchCriteria>
              <Criterion>
                 <HotelRef HotelCode="HOTEL1"/>
              </Criterion>
           </HotelSearchCriteria>
        </AvailRequestSegment>
     </AvailRequestSegments>
  </OTA_HotelAvailRQ>

我能够从 SOAP 服务器获得响应,请参阅下面的输出,但请注意 HotelRef 为空。如何访问属性?

stdClass Object ( [AvailRequestSegments] => stdClass Object ( [AvailRequestSegment] => stdClass Object ( [HotelSearchCriteria] => stdClass Object ( [Criterion] => stdClass Object ( [HotelRef] => )

4

1 回答 1

0
$strXML = 'theRequestXML_OTA_HotelAvailRQ';
$objSimpleXML = new SimpleXMLElement($strXML,NULL,NULL,"http://schemas.xmlsoap.org/soap/envelope/");
foreach ($objSimpleXML->children() as $objItems) {

    $strHotelCode = $objItems->AvailRequestSegments->AvailRequestSegment->HotelSearchCriteria->Criterion->HotelRef->attributes()->{'HotelCode'};
}
于 2013-06-04T12:31:14.470 回答