title: Accessing data from simpleXMLElementObject
body: <p>I am getting XML data from an api that looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;PP&gt;
  &lt;row merchant_id="" customer_code="" billing_name="" account_status="Active"  created_date="2013-07-31 13:22:32.687" last_modified_date="2013-07-31 13:23:41.827" last_trans_date="2013-07-31 13:35:59.257" billing_address1="rd." billing_address2="" billing_city="Lower" billing_province_id="" billing_country_id="CA" billing_postal="" billing_email_address="" billing_phone="" velocity_group="" profile_group="" account_ref="12345" card_expiry="0713" cc_notification="" ref1="" ref2="" ref3="" ref4="" ref5="" /&gt;
  &lt;/PP&gt;
  </code></pre>
  
  <p>I am trying to either access the data in php or turn it into an easily accessible array. I have tried something like this:</p>
  
  <pre><code>$xml = simplexml_load_string($resp);
  
  
  $fields = array();
  foreach ($xml-&gt;field as $f) {
      $f = (array) $f-&gt;attributes();
      $fields[] = $f['@attributes'];
  }
  </code></pre>
  
  <p>But cannot access the data from that.</p>
  
  <p>When I print that data it shows as this:</p>
  
  <p>SimpleXMLElement Object ( [row] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [merchant_id] => [customer_code] => [billing_name] => John Doe [account_status] => Active [created_date] => 2013-08-01 08:26:31.710 [last_modified_date] => 2013-08-01 08:26:52.170 [last_trans_date] => [billing_address1] => [billing_address2] => [billing_city] => [billing_province_id] => [billing_country_id] => CA [billing_postal] => [billing_email_address] => .ca [billing_phone] => [velocity_group] => [profile_group] => [account_ref] => [card_expiry] => 0813 [cc_notification] => [ref1] => [ref2] => [ref3] => [ref4] => [ref5] => ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [merchant_id] => [customer_code] => 12345 [billing_name] =>  [account_status] => Active [created_date] => 2013-07-31 13:22:32.687 [last_modified_date] => 2013-07-31 13:23:41.827 [last_trans_date] => 2013-07-31 13:35:59.257 [billing_address1] =>  rd. [billing_address2] => [billing_city] => Lowe [billing_province_id] => [billing_country_id] => CA [billing_postal] => [billing_email_address] =>  [billing_phone] => [velocity_group] => [profile_group] => [account_ref] => 12345 [card_expiry] => 0713 [cc_notification] => [ref1] => [ref2] => [ref3] => [ref4] => [ref5] => ) ) ) )</p>
  
  <p>Can anyone help me out on either just accessing the data or help me put this into an array.</p>
  
  <p>Thanks</p>