title: converting SOAP XML response to a PHP object or array
body: <p>I'm using cURL to send an request to a SOAP service, I send in POST Body the XML containing parameters, in response I receive:</p>
  
  <p>Web service: <a href="http://lcbtestxmlv2.ivector.co.uk/soap/book.asmx?WSDL">http://lcbtestxmlv2.ivector.co.uk/soap/book.asmx?WSDL</a></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
         &lt;soap:Body&gt;
            &lt;SearchResponse xmlns="http://ivectorbookingxml/"&gt;
               &lt;SearchResult&gt;
                  &lt;ReturnStatus&gt;
                     &lt;Success&gt;true&lt;/Success&gt;
                     &lt;Exception /&gt;
                  &lt;/ReturnStatus&gt;
                  &lt;SearchURL&gt;http://www.lowcostholidays.fr/dl.aspx?p=0,8,5,0&amp;amp;date=10/05/2013&amp;amp;duration=15&amp;amp;room1=2,1,0_5&amp;amp;regionid=9&lt;/SearchURL&gt;
                  &lt;PropertyResults&gt;
                     &lt;PropertyResult&gt;
                        &lt;TotalProperties&gt;215&lt;/TotalProperties&gt;
                        &lt;PropertyID&gt;1795&lt;/PropertyID&gt;
                        &lt;PropertyName&gt;Hotel Gaddis&lt;/PropertyName&gt;
                        &lt;Rating&gt;3.0&lt;/Rating&gt;
                        &lt;Country&gt;Egypte&lt;/Country&gt;
                        &lt;Resort&gt;Louxor&lt;/Resort&gt;
                        &lt;Strapline&gt;Cet établissement confortable propose un très bon service à un bon rapport qualité-prix. Cet hôtel de 6 étages compte 55 chambres et comprend une terrasse, une réception avec coffre-fort et ascenseur,&lt;/Strapline&gt;
                        &lt;Description&gt;Cet établissement confortable propose un très bon service à un bon rapport qualité-prix. Cet hôtel de 6 étages compte 55 chambres et comprend une terrasse, une réception avec coffre-fort et ascenseur,...&lt;/Description&gt;
                        &lt;CMSBaseURL&gt;http://lcbtestxml1.ivector.co.uk/content/DataObjects/Property/Image/&lt;/CMSBaseURL&gt;
                        &lt;MainImage&gt;image_1795_v1.jpg&lt;/MainImage&gt;
                        &lt;MainImageThumbnail&gt;imagethumb_1795_v1.jpg&lt;/MainImageThumbnail&gt;
                        &lt;SearchURL&gt;http://www.lowcostholidays.fr/dl.aspx?p=0,8,5,0&amp;amp;date=10/05/2013&amp;amp;duration=15&amp;amp;room1=2,1,0_5&amp;amp;regionid=9&amp;amp;propertyid=1795&lt;/SearchURL&gt;
                        &lt;RoomTypes&gt;
                           &lt;RoomType&gt;
                              &lt;Seq&gt;1&lt;/Seq&gt;
                              &lt;PropertyRoomTypeID&gt;690039000&lt;/PropertyRoomTypeID&gt;
                              &lt;MealBasisID&gt;3&lt;/MealBasisID&gt;
                              &lt;RoomType&gt;Twin/double Room&lt;/RoomType&gt;
                              &lt;RoomView /&gt;
                              &lt;MealBasis&gt;Petit Déjeuner&lt;/MealBasis&gt;
                              &lt;NonRefundableRates&gt;false&lt;/NonRefundableRates&gt;
                              &lt;SubTotal&gt;150.58&lt;/SubTotal&gt;
                              &lt;Discount&gt;0&lt;/Discount&gt;
                              &lt;Total&gt;150.58&lt;/Total&gt;
                              &lt;Adults&gt;2&lt;/Adults&gt;
                              &lt;Children&gt;1&lt;/Children&gt;
                              &lt;Infants&gt;0&lt;/Infants&gt;
                              &lt;Errata /&gt;
                           &lt;/RoomType&gt;
                           &lt;RoomType&gt;
                              &lt;Seq&gt;1&lt;/Seq&gt;
                              &lt;PropertyRoomTypeID&gt;690039001&lt;/PropertyRoomTypeID&gt;
                              &lt;MealBasisID&gt;7&lt;/MealBasisID&gt;
                              &lt;RoomType&gt;Twin/double Room&lt;/RoomType&gt;
                              &lt;RoomView /&gt;
                              &lt;MealBasis&gt;Demi-Pension&lt;/MealBasis&gt;
                              &lt;NonRefundableRates&gt;false&lt;/NonRefundableRates&gt;
                              &lt;SubTotal&gt;291.64&lt;/SubTotal&gt;
                              &lt;Discount&gt;0&lt;/Discount&gt;
                              &lt;Total&gt;291.64&lt;/Total&gt;
                              &lt;Adults&gt;2&lt;/Adults&gt;
                              &lt;Children&gt;1&lt;/Children&gt;
                              &lt;Infants&gt;0&lt;/Infants&gt;
                              &lt;Errata /&gt;
                           &lt;/RoomType&gt;
                           &lt;RoomType&gt;
                              &lt;Seq&gt;1&lt;/Seq&gt;
                              &lt;PropertyRoomTypeID&gt;690039002&lt;/PropertyRoomTypeID&gt;
                              &lt;MealBasisID&gt;5&lt;/MealBasisID&gt;
                              &lt;RoomType&gt;Double/twin Room&lt;/RoomType&gt;
                              &lt;RoomView /&gt;
                              &lt;MealBasis&gt;Pension Complète&lt;/MealBasis&gt;
                              &lt;NonRefundableRates&gt;false&lt;/NonRefundableRates&gt;
                              &lt;SubTotal&gt;529.22&lt;/SubTotal&gt;
                              &lt;Discount&gt;0&lt;/Discount&gt;
                              &lt;Total&gt;529.22&lt;/Total&gt;
                              &lt;Adults&gt;2&lt;/Adults&gt;
                              &lt;Children&gt;1&lt;/Children&gt;
                              &lt;Infants&gt;0&lt;/Infants&gt;
                              &lt;Errata /&gt;
                           &lt;/RoomType&gt;
                        &lt;/RoomTypes&gt;
                     &lt;/PropertyResult&gt;
                  &lt;/PropertyResults&gt;
               &lt;/SearchResult&gt;
            &lt;/SearchResponse&gt;
         &lt;/soap:Body&gt;
      &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>I don't have enough experience with XML data. I spent hours trying to convert the XML response to a PHP object or  array, but without any success.</p>
  
  <p>I need to read all PropertyResults.</p>
  
  <p>PHP Code:</p>
  
  <pre><code>$xml = simplexml_load_string($soap_xml_result);
  
  $xml-&gt;registerXPathNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/');
  $xml-&gt;registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
  $xml-&gt;registerXPathNamespace('xsd', 'http://www.w3.org/2001/XMLSchema');
  
  $test = (string) $xml-&gt;Body-&gt;SearchResponse-&gt;SearchResult-&gt;SearchURL;
  var_export($test);
  </code></pre>