开发者

How to display values in curl xml response using php?

开发者 https://www.devze.com 2023-03-18 11:44 出处:网络
Can we change this xml response into array. Please help me. <?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=

Can we change this xml response into array. Please help me.

  <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
      <ns1:OTA_HotelAvailRQResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://components.hotelsv3">
           <OTA_HotelAvailRQReturn xsi:type="xsd:string"><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
                <OTA_HotelAvailRS Version=&quot;1.0&quot;>
                     <Success Id=&quot;141334&quot;/>

                     <Properties>

                          <Property HotelCityCode=&quot;ELS&quot; HotelCode=&quot;26824&quot; HotelName=&quot;Premier Hotel Regent - Demo&quot;>
                                    <RelativePosition Direction=&quot;&quot; Distance=&quot;0&quot; DistanceUnitName=&quot;&quot;/>

                               <EssentialInfo>

                               </EssentialInfo>
                               <RoomStays>

                                    <RoomStay>
                                         <RatePlans>
                                              <RatePlan RatePlanCode=&quot;71316&quot;/>

                                         </RatePlans>
                                         <RoomRates>
                                              <RoomRate>
                                                   <Rates>
                                                        <Rate EffectiveDate=&quot;2011-10-14&quot; ExpireDate=&quot;2011-10-15&quot;>

                                                             <Base Amount=&quot;114.00&quot; CurrencyCode=&quot;EUR&quot;/>
                                                             <RateDescription Adults=&quot;1&quot; Availability=&quot;A&quot; Children=&quot;0&quot; RoomNum=&quot;1&quot;>

                                                                  Standard 
                                                             </RateDescription>
                                                        </Rate>
                                                   </Rates>
                                              </RoomRate>
                                         </RoomRates>

                                         <Meals Description=&quot;Breakfast Buffet&quot; MealType=&quot;Breakfast&quot;/>


                                           </RoomStay>

                               </RoomStays>
                               <Promotions/>

                               <AdditionalInfo>
                                    <HotelStarDetail rating=&quot;3&quot;/>


                                    <HotelImages>

                                         <HotelImage Type=&quot;&quot; URL=&quot;http://image1.urlforimages.com/1204258/Premier-Hotel-Regent_guest.jpg&quot;/>

                                                </HotelImages>

                                    <HotelDescription>
                                         <LongDescription>  guest rooms  175 guestrooms</LongDescription>

                                    </HotelDescription>
                               </AdditionalInfo>

                          </Property>

                          <Property HotelCityCode=&quot;ELS&quot; HotelCode=&quot;26823&quot; HotelName=&quot;Mpongo Private Game Reserve - Demo&quot;>

                                    <RelativePosition Direction=&quot;&quot; Distance=&quot;0&quot; DistanceUnitName=&quot;&quot;/>
                               <EssentialInfo>

                               </EssentialInfo>
                               <RoomStays>


                                    <RoomStay>
                                         <RatePlans>
                                              <RatePlan RatePlanCode=&quot;71314&quot;/>
                                         </RatePlans>
                                         <RoomRates>

                                              <RoomRate>
                                                   <Rates>
                                                        <Rate EffectiveDate=&quot;2011-10-14&quot; ExpireDate=&quot;2011-10-15&quot;>
                                                             <Base Amount=&quot;117.00&quot; CurrencyCode=&quot;EUR&quot;/>

                   开发者_开发知识库                                          <RateDescription Adults=&quot;1&quot; Availability=&quot;A&quot; Children=&quot;0&quot; RoomNum=&quot;1&quot;>
                                                                  Standard 
                                                             </RateDescription>

                                                        </Rate>
                                                   </Rates>
                                              </RoomRate>
                                         </RoomRates>

                                         <Meals Description=&quot;Half board&quot; MealType=&quot;HalfBoard&quot;/>


                                           </RoomStay>

                                    <RoomStay>
                                         <RatePlans>
                                              <RatePlan RatePlanCode=&quot;71315&quot;/>
                                         </RatePlans>

                                         <RoomRates>
                                              <RoomRate>
                                                   <Rates>
                                                        <Rate EffectiveDate=&quot;2011-10-14&quot; ExpireDate=&quot;2011-10-15&quot;>
                                                             <Base Amount=&quot;174.00&quot; CurrencyCode=&quot;EUR&quot;/>

                                                             <RateDescription Adults=&quot;1&quot; Availability=&quot;A&quot; Children=&quot;0&quot; RoomNum=&quot;1&quot;>
                                                                  River Lodge 
                                                             </RateDescription>

                                                        </Rate>
                                                   </Rates>
                                              </RoomRate>
                                         </RoomRates>

                                         <Meals Description=&quot;Half board&quot; MealType=&quot;HalfBoard&quot;/>


                                           </RoomStay>

                               </RoomStays>
                               <Promotions/>

                               <AdditionalInfo>
                                    <HotelStarDetail rating=&quot;4&quot;/>


                                    <HotelImages>

                                         <HotelImage Type=&quot;&quot; URL=&quot;http://image1.urlforimages.com/1204253/Mpongo-Private_guest.jpg&quot;/>

                                                </HotelImages>

                                    <HotelDescription>
                                         <LongDescription>  Accommodation: 18 guestrooms</LongDescription>

                                    </HotelDescription>
                               </AdditionalInfo>

                          </Property>
                     </Properties>
           </OTA_HotelAvailRS></OTA_HotelAvailRQReturn>
      </ns1:OTA_HotelAvailRQResponse>

 </soapenv:Body>


Have a look at http://www.php.net/manual/en/class.domdocument.php

<?php

$doc = new DOMDocument();
$doc->loadXML($xml);
$nodes = $doc->getElementsByTagName('*');
$values = array();

foreach($nodes as $node) {
  $values[] = $node->nodeValue;
}

?>
0

精彩评论

暂无评论...
验证码 换一张
取 消