0

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>

1 Answer 1

1

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;
}

?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.