我有一个 XML Feed 来跟踪包裹
<xyz_name_of_company-objects version="1.0">
<object pk="1" model="awb">
<field type="BigIntegerField" name="awb_number">5818537179673</field>
<field type="CharField" name="origin">AMSTERDAM</field>
<field type="CharField" name="destination">BERLIN</field>
<field type="CharField" name="current_location_name">BRUSSELS</field>
<field type="CharField" name="current_location_code">BRSL</field>
<field name="scans">
<object pk="1" model="scan_stages">
<field type="DateTimeField" name="updated_on">17 March, 2019, 03:10 </field>
<field type="CharField" name="status">In-Transit</field>
<field type="CharField" name="reason_code_number">002</field>
<field type="CharField" name="scan_status">PICKUP</field>
<field type="CharField" name="location_city">AMSTERDAM</field>
<field type="CharField" name="location_type">Hub</field>
<field type="CharField" name="city_name">AMSTERDAM</field>
<field type="CharField" name="Employee">JOEL - O94383</field>
</object>
<object pk="2" model="scan_stages">
<field type="DateTimeField" name="updated_on">18 March, 2019, 22:22 </field>
<field type="CharField" name="status">Bag scanned at Hub</field>
<field type="CharField" name="reason_code"> - </field>
<field type="CharField" name="reason_code_number">003</field>
<field type="CharField" name="scan_status">IN</field>
<field type="CharField" name="location">I1H</field>
<field type="CharField" name="location_city">AMSTERDAM</field>
<field type="CharField" name="location_type">Hub</field>
<field type="CharField" name="city_name">AMSTERDAM</field>
<field type="CharField" name="Employee">ELLEN - 49821</field>
</object>
</field>
</object>
</xyz_name_of_company-objects>
到目前为止,我一直在使用以下代码行来获取主要数据,例如 awb_number、origin、destination
$url = A Get URL with Credentials
$xml = simplexml_load_file($url);
$awb = $xml->object->field[0];
$origin= $xml->object->field[1];
$destination = $xml->object->field[3];
现在我关心的是获取数据
对象 pk="1" 模型="scan_stages"
对于不同的扫描阶段,在我的情况下,我称之为扫描状态。
[仅供参考:这些是快递公司网络中包裹的不同阶段]。
慕妹3242003