Hello,
I am trying to parse the Dell API reponse to get the warranty status and date for my computers
here is the code I use:
$doc = new DOMDocument();
$doc->load($feedURL);
$arrFeeds = array();
foreach ($doc->getElementsByTagName(‘AssetEntitlement’) as $node) {
$itemRSS = array (
‘MachineDescription’ => $node->getElementsByTagName(‘MachineDescription’)->item(0)->nodeValue,
‘desc’ => $node->getElementsByTagName(‘description’)->item(0)->nodeValue,
‘OrderNumber’ => $node->getElementsByTagName(‘OrderNumber’)->item(0)->nodeValue,
‘ShipDate’ => $node->getElementsByTagName(‘ShipDate’)->item(0)->nodeValue,
‘WEndDate’ => $node->getElementsByTagName(‘EndDate’)->item(0)->nodeValue,
‘Warranties’ => $node->getElementsByTagName(‘EndDate’)->item(1)->nodeValue,
‘SL0’ => $node->getElementsByTagName(‘ServiceLevelDescription’)->item(0)->nodeValue,
‘SL1’ => $node->getElementsByTagName(‘ServiceLevelDescription’)->item(1)->nodeValue,
‘SL2’ => $node->getElementsByTagName(‘ServiceLevelDescription’)->item(2)->nodeValue,
‘SL3’ => $node->getElementsByTagName(‘ServiceLevelDescription’)->item(3)->nodeValue,
);
array_push($arrFeeds, $itemRSS);
print_r($arrFeeds);
}
foreach($arrFeeds as $arrItem)
{
$ServiceTag = $arrItem[‘ServiceTag’];
$MachineDescription = $arrItem[‘MachineDescription’];
$OrderNum = $arrItem[‘OrderNumber’];
$ShipDate = codeDate($arrItem[‘ShipDate’]);
$Warranties = codeDate($arrItem[‘Warranties’]);
$WEndDate = codeDate($arrItem[‘WEndDate’]);
$ServiceLevelDescription = $arrItem[‘SL0’].’ - ‘.$arrItem[‘SL1’].’ - ‘.$arrItem[‘SL2’].’ - '.$arrItem[‘SL3’];
}
$reponsetab[“ServiceTag”]=$ServiceTag;
$reponsetab[“OrderNum”]=$OrderNum;
$reponsetab[“SystemID”]=$SystemID;
$reponsetab[“SystemType”]=$SystemType;
$reponsetab[“SystemModel”]=$MachineDescription;
$reponsetab[“ShipDate”]= $ShipDate;
$reponsetab[“Warrantystart”]=$ShipDate;
$reponsetab[“Warrantyend”]=$WEndDate;
$reponsetab[“Warrantydaysleft”]=$Warrantydaysleft;
$reponsetab[“Warrantystatus”]=$ServiceLevelDescription;
//Send Data back to javascript formated in JSON
//var_dump($reponsetab);
require_once("…/…/…/includes/connect.inc");
if ($maction==‘updatetable’)
{
connect();
//update intranet table
$query_update=“UPDATE intranet_parcinfo SET Shipdate=’$ShipDate’,StartDate=’$ShipDate’,EndDate=’$WEndDate’,Wdaysleft=’$Warrantydaysleft’,Wstatus=’$ServiceLevelDescription’ where Serial=’$Serial’”;
echo $query_update;
mysql_query($query_update) or die ($query_update.'Error : '.htmlspecialchars (mysql_error()));
}
echo json_encode($reponsetab);
and here is the xml file:
https://www.pastiebin.com/5b6c6a00d6a16
Thanks for your lights!
Cedric