title: How to parse SOAP Response Containing Node Attributes in PHP
body: <p>I am having a difficult time understanding how to view/use an XML result from a SOAP call in PHP.  I have a script which makes a SOAP request to a script on another server,  and it sends an XML response. That response has a number of nested nodes,  some of which have attributes.  I am able to make the SOAP call and get the response,  however,  using var_dump and print_r gives me the XML array without the attributes.</p>
  
  <p>Here is the code breakdown:</p>
  
  <p><strong>Code Snippet in PHPH script which makes the SOAP request</strong></p>
  
  <pre><code>use_soap_error_handler(true);
  $client = new SoapClient(null, array("uri" =&gt; "Lic", "location" =&gt; "http://mydomain.com/Lic.cgi", "trace" =&gt; 1));
  $assets = $client-&gt;Menu($email,$account_id);
  </code></pre>
  
  <p><strong>Expected Response</strong>
  The call generates the following (style of) XML result on the other server:</p>
  
  <pre><code>&lt;opt&gt;
      &lt;Account&gt;
          &lt;Asset id="1000"&gt;
              &lt;Menu type="simple"&gt;Software&lt;/Menu&gt;
          &lt;/Asset&gt;
          &lt;Asset id="2000"&gt;
              &lt;Menu type="modal"&gt;Software&lt;/Menu&gt;
              &lt;Menu type="simple"&gt;Demo&lt;/Menu&gt;
          &lt;/Asset&gt;
      &lt;/Account&gt;
  &lt;/opt&gt;
  </code></pre>
  
  <p>Notice that Asset and Menu nodes have node attributes (id, type, etc).</p>
  
  <p><strong>Actual Results</strong>
  When I do a var_dump or print_r on $assets,  I do get successful results,  but I cannot see the attributes (id,  type, etc) anywhere.   The ultimate goal is to take XML array and write the data to a MySQL table,  but I would need the attributes as well,  and days of searching has not yielded the missing piece on how I can access the full data results in PHP.</p>
  
  <p><strong>VAR DUMP</strong>
  The var_dump would result in something like:</p>
  
  <pre><code>object(stdClass)#44 (1) {
    ["Account"]=&gt;
    object(stdClass)#45 (1) {
      ["Asset"]=&gt;
      array(2) {
        [0]=&gt;
        object(stdClass)#46 (1) {
          ["Menu"]=&gt;
          string(12) "Software"
        }
    ....
  </code></pre>
  
  <p><strong>PRINT_R</strong>
  And print_r($assets) gives something like:</p>
  
  <pre><code>stdClass Object
  (
      [Account] =&gt; stdClass Object
      (
          [Asset] =&gt; Array
          (
          [0] =&gt; stdClass Object
          (
              [Menu] =&gt; Software
          )
          [1] =&gt; stdClass Object
          (
          [Menu] =&gt; Array
              (
              [0] =&gt; Software
                  [1] =&gt; Demo
              )
              ...    
  </code></pre>
  
  <p>Aside from var_dump and print_r,  is there another way to view the results,  in order to see the full data,  including the attributes?</p>
  
  <p>Thanks in advance,  and I apologize if I'm not asking the question properly (if so, please let me know so that I can rephrase using the right terminology).</p>