gets data from xml in php
<p>I Want get each <code>&lt;object pk='1'&gt;, &lt;object pk='2'&gt;</code> and its  <code>&lt;field&gt;</code> attribute like <code>update_on</code> and its each <code>&lt;field&gt;</code> text LIKE   <code>05 Apr, 2013, 19:40 hrs</code> but I can not fetch all data. please help me</p>

<p>I tried Below Code,below code fetch only first object's field</p>

<pre><code>$xml = new SimpleXMLElement($server_output);
echo "&lt;ul&gt;";

foreach($xml-&gt;object-&gt;field as $key =&gt; $value)
{ ?&gt;
&lt;li style="list-style:none;"&gt;&lt;?php echo $value['name'] .'-' ?&gt; &lt;span&gt;&lt;?php echo $value; ?&gt; &lt;/span&gt;&lt;li&gt;
&lt;?php 
if($value['name'] == 'scans')
{

            print_r($value-&gt;object);


}
  }
 echo "&lt;/ul&gt;";
</code></pre>

<p>Below Xml Code</p>

<pre><code>&lt;ecomexpress-objects version="1.0"&gt;
     &lt;object pk="1" model="awb"&gt;
        &lt;field type="BigIntegerField" name="awb_number"&gt;700054480&lt;/field&gt;
        &lt;field type="CharField" name="orderid"&gt;5012&lt;/field&gt;
        &lt;field type="FloatField" name="actual_weight"&gt;0.5&lt;/field&gt;
        &lt;field type="CharField" name="origin"&gt;DELHI-DSW&lt;/field&gt;
        &lt;field type="CharField" name="destination"&gt;DELHI-DLN&lt;/field&gt;
        &lt;field type="CharField" name="customer"&gt;Ecom Express Private Limited - 32012&lt;/field&gt;
        &lt;field type="CharField" name="consignee"&gt;MUKESH KUMAR GUPTA&lt;/field&gt;
        &lt;field type="CharField" name="pickupdate"&gt;11-Feb-2013&lt;/field&gt;
        &lt;field type="CharField" name="status"&gt;Delivered / Closed&lt;/field&gt;
        &lt;field type="CharField" name="reason_code"/&gt;
        &lt;field type="CharField" name="reason_code_description"/&gt;
        &lt;field type="CharField" name="reason_code_number"&gt;999&lt;/field&gt;
        &lt;field type="CharField" name="receiver"&gt;mukesh 9999488339&lt;/field&gt;
        &lt;field type="CharField" name="expected_date"&gt;12-Feb-2013&lt;/field&gt;
        &lt;field type="CharField" name="last_update_date"&gt;05-Apr-2013&lt;/field&gt;
        &lt;field type="CharField" name="delivery_date"&gt;2013-02-17 11:26:00&lt;/field&gt;
        &lt;field type="CharField" name="ref_awb"&gt;None&lt;/field&gt;
        &lt;field type="CharField" name="rts_shipment"/&gt;
        &lt;field type="CharField" name="system_delivery_update"&gt;2013-02-17 11:26:00&lt;/field&gt;
        &lt;field type="CharField" name="rts_system_delivery_status"/&gt;
        &lt;field name="scans"&gt;
         &lt;object pk="1" model="scan_stages"&gt;
          &lt;field type="DateTimeField" name="updated_on"&gt;05 Apr, 2013, 19:40 hrs&lt;/field&gt;
           &lt;field type="CharField" name="status"&gt;SAL Tally closed&lt;/field&gt;
           &lt;field type="CharField" name="reason_code"/&gt;
           &lt;field type="CharField" name="reason_code_number"/&gt;
           &lt;field type="CharField" name="location"&gt;DLN&lt;/field&gt;
           &lt;field type="CharField" name="Employee"&gt;Umesh Jaswanti - 10015&lt;/field&gt;
         &lt;/object&gt;
         &lt;object pk="2" model="scan_stages"&gt;
           &lt;field type="DateTimeField" name="updated_on"&gt;05 Apr, 2013, 19:39 hrs&lt;/field&gt;
           &lt;field type="CharField" name="status"&gt;SAL Tally closed&lt;/field&gt;
           &lt;field type="CharField" name="reason_code"/&gt;
           &lt;field type="CharField" name="reason_code_number"/&gt;
           &lt;field type="CharField" name="location"&gt;DLN&lt;/field&gt;
           &lt;field type="CharField" name="Employee"&gt;Umesh Jaswanti - 10015&lt;/field&gt;
         &lt;/object&gt;
         &lt;object pk="3" model="scan_stages"&gt;
           &lt;field type="DateTimeField" name="updated_on"&gt;05 Apr, 2013, 19:39 hrs&lt;/field&gt;
           &lt;field type="CharField" name="status"&gt;SAL Tally closed&lt;/field&gt;
           &lt;field type="CharField" name="reason_code"/&gt;
           &lt;field type="CharField" name="reason_code_number"/&gt;
           &lt;field type="CharField" name="location"&gt;DLN&lt;/field&gt;
           &lt;field type="CharField" name="Employee"&gt;Umesh Jaswanti - 10015&lt;/field&gt;
          &lt;/object&gt;
        &lt;/field&gt;
       &lt;/object&gt;
&lt;/ecomexpress-objects&gt;
</code></pre>