Get PHP Var_Dump Output in XML : <p>I am using SoapClient to return data from a Web Service provider. The data is returned in a typical object/array PHP format. I want to return it in XML. </p>

<p>Here is my code to call the Web Service (I have omitted my username and password):</p>

<pre><code>&lt;?php
//Calling Chrome ADS with Build Data
 $client = new     SoapClient('http://services.chromedata.com/Description/7b?wsdl');
 $account = ['number'=&gt;"", 'secret'=&gt;"", 'country'=&gt;"US",    'language'=&gt;"en"];
 $switch =  ["ShowAvailableEquipment", "ShowExtendedTechnicalSpecifications", "ShowExtendedDescriptions"];
 $vin = $_POST["b12"];

 $result = $client-&gt;describeVehicle([
 'accountInfo' =&gt; $account,
 'switch' =&gt; $switch,
  'vin' =&gt; $vin
]);

var_dump ($result);

 ?&gt;
</code></pre>

<p>Here is how the data is currently outputted:</p>

<pre><code>object(stdClass)#2 (18) {
  ["responseStatus"]=&gt;
  object(stdClass)#3 (2) {
    ["responseCode"]=&gt;
    string(10) "Successful"
    ["description"]=&gt;
    string(10) "Successful"
  }
  ["vinDescription"]=&gt;
   object(stdClass)#4 (11) {
    ["WorldManufacturerIdentifier"]=&gt;
    string(17) "Germany Audi Nsu "
    ["restraintTypes"]=&gt;
    array(5) {
      [0]=&gt;
  object(stdClass)#5 (3) {
    ["group"]=&gt;
    object(stdClass)#6 (2) {
      ["_"]=&gt;
      string(6) "Safety"
      ["id"]=&gt;
      int(9)
    }
    ["header"]=&gt;
    object(stdClass)#7 (2) {
      ["_"]=&gt;
      string(17) "Air Bag - Frontal"
      ["id"]=&gt;
      int(38)
    }
    ["category"]=&gt;
    object(stdClass)#8 (2) {
      ["_"]=&gt;
      string(14) "Driver Air Bag"
      ["id"]=&gt;
      int(1001)
    }
  }
</code></pre>

<p>Here is how I want the data to be outputted (this is from when I run the request through SoapUI):</p>

<pre><code>  &lt;VehicleDescription country="US" language="en" modelYear="2008" bestMakeName="Audi" bestModelName="S4" bestStyleName="5dr Avant Wgn" xmlns="urn:description7b.services.chrome.com"&gt;
     &lt;responseStatus responseCode="Successful" description="Successful"/&gt;
     &lt;vinDescription vin="WAUUL78E38A092113" modelYear="2008" division="Audi" modelName="S4" styleName="5dr Avant Wgn" bodyType="Wagon 4 Dr." drivingWheels="AWD" builddata="no"&gt;
        &lt;WorldManufacturerIdentifier&gt;Germany Audi Nsu&lt;/WorldManufacturerIdentifier&gt;
        &lt;restraintTypes&gt;
           &lt;group id="9"&gt;Safety&lt;/group&gt;
           &lt;header id="38"&gt;Air Bag - Frontal&lt;/header&gt;
           &lt;category id="1001"&gt;Driver Air Bag&lt;/category&gt;
        &lt;/restraintTypes&gt;
        &lt;restraintTypes&gt;
           &lt;group id="9"&gt;Safety&lt;/group&gt;
           &lt;header id="38"&gt;Air Bag - Frontal&lt;/header&gt;
           &lt;category id="1002"&gt;Passenger Air Bag&lt;/category&gt;
        &lt;/restraintTypes&gt;
        &lt;restraintTypes&gt;
           &lt;group id="9"&gt;Safety&lt;/group&gt;
           &lt;header id="39"&gt;Air Bag - Side&lt;/header&gt;
           &lt;category id="1005"&gt;Front Side Air Bag&lt;/category&gt;
        &lt;/restraintTypes&gt;
        &lt;restraintTypes&gt;
           &lt;group id="9"&gt;Safety&lt;/group&gt;
           &lt;header id="39"&gt;Air Bag - Side&lt;/header&gt;
           &lt;category id="1007"&gt;Front Head Air Bag&lt;/category&gt;
        &lt;/restraintTypes&gt;
</code></pre>
