I Want get each <object pk='1'>, <object pk='2'>
and its <field>
attribute like update_on
and its each <field>
text LIKE 05 Apr, 2013, 19:40 hrs
but I can not fetch all data. please help me
I tried Below Code,below code fetch only first object's field
$xml = new SimpleXMLElement($server_output);
echo "<ul>";
foreach($xml->object->field as $key => $value)
{ ?>
<li style="list-style:none;"><?php echo $value['name'] .'-' ?> <span><?php echo $value; ?> </span><li>
<?php
if($value['name'] == 'scans')
{
print_r($value->object);
}
}
echo "</ul>";
Below Xml Code
<ecomexpress-objects version="1.0">
<object pk="1" model="awb">
<field type="BigIntegerField" name="awb_number">700054480</field>
<field type="CharField" name="orderid">5012</field>
<field type="FloatField" name="actual_weight">0.5</field>
<field type="CharField" name="origin">DELHI-DSW</field>
<field type="CharField" name="destination">DELHI-DLN</field>
<field type="CharField" name="customer">Ecom Express Private Limited - 32012</field>
<field type="CharField" name="consignee">MUKESH KUMAR GUPTA</field>
<field type="CharField" name="pickupdate">11-Feb-2013</field>
<field type="CharField" name="status">Delivered / Closed</field>
<field type="CharField" name="reason_code"/>
<field type="CharField" name="reason_code_description"/>
<field type="CharField" name="reason_code_number">999</field>
<field type="CharField" name="receiver">mukesh 9999488339</field>
<field type="CharField" name="expected_date">12-Feb-2013</field>
<field type="CharField" name="last_update_date">05-Apr-2013</field>
<field type="CharField" name="delivery_date">2013-02-17 11:26:00</field>
<field type="CharField" name="ref_awb">None</field>
<field type="CharField" name="rts_shipment"/>
<field type="CharField" name="system_delivery_update">2013-02-17 11:26:00</field>
<field type="CharField" name="rts_system_delivery_status"/>
<field name="scans">
<object pk="1" model="scan_stages">
<field type="DateTimeField" name="updated_on">05 Apr, 2013, 19:40 hrs</field>
<field type="CharField" name="status">SAL Tally closed</field>
<field type="CharField" name="reason_code"/>
<field type="CharField" name="reason_code_number"/>
<field type="CharField" name="location">DLN</field>
<field type="CharField" name="Employee">Umesh Jaswanti - 10015</field>
</object>
<object pk="2" model="scan_stages">
<field type="DateTimeField" name="updated_on">05 Apr, 2013, 19:39 hrs</field>
<field type="CharField" name="status">SAL Tally closed</field>
<field type="CharField" name="reason_code"/>
<field type="CharField" name="reason_code_number"/>
<field type="CharField" name="location">DLN</field>
<field type="CharField" name="Employee">Umesh Jaswanti - 10015</field>
</object>
<object pk="3" model="scan_stages">
<field type="DateTimeField" name="updated_on">05 Apr, 2013, 19:39 hrs</field>
<field type="CharField" name="status">SAL Tally closed</field>
<field type="CharField" name="reason_code"/>
<field type="CharField" name="reason_code_number"/>
<field type="CharField" name="location">DLN</field>
<field type="CharField" name="Employee">Umesh Jaswanti - 10015</field>
</object>
</field>
</object>
</ecomexpress-objects>