I'm parsing the Bing API for traffic accidents in the area, I use the URL
A sample result is:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Copyright>Copyright © 2015 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.</Copyright>
<BrandLogoUri>http://dev.virtualearth.net/Branding/logo_powered_by.png</BrandLogoUri>
<StatusCode>200</StatusCode>
<StatusDescription>OK</StatusDescription>
<AuthenticationResultCode>ValidCredentials</AuthenticationResultCode>
<TraceId>b6b8a1174b3c40738f754f3ed0d443db|BN20130731|02.00.174.2300|BN20010843</TraceId>
<ResourceSets>
<ResourceSet>
<EstimatedTotal>3</EstimatedTotal>
<Resources>
<TrafficIncident>
<Point>
<Latitude>38.8677</Latitude>
<Longitude>-94.80368</Longitude>
</Point>
<Source>4</Source>
<IncidentId>9000000669</IncidentId>
<LastModifiedUTC>2015-06-24T15:12:15.0238037Z</LastModifiedUTC>
<StartTimeUTC>2015-05-20T16:45:09Z</StartTimeUTC>
<EndTimeUTC>2015-07-10T17:19:00Z</EndTimeUTC>
<Type>Miscellaneous</Type>
<Severity>Serious</Severity>
<Verified>true</Verified>
<RoadClosed>true</RoadClosed>
<Description>is closed between I-35 and I-35 - closed</Description>
<ToPoint>
<Latitude>38.8677</Latitude>
<Longitude>-94.80368</Longitude>
</ToPoint>
</TrafficIncident>
<TrafficIncident>
<Point>
<Latitude>38.95653</Latitude>
<Longitude>-94.74221</Longitude>
</Point>
<Source>4</Source>
<IncidentId>9000000690</IncidentId>
<LastModifiedUTC>2015-06-24T15:12:15.0238037Z</LastModifiedUTC>
<StartTimeUTC>2015-05-27T17:08:07Z</StartTimeUTC>
<EndTimeUTC>2015-10-05T09:04:00Z</EndTimeUTC>
<Type>Miscellaneous</Type>
<Severity>Serious</Severity>
<Verified>true</Verified>
<RoadClosed>true</RoadClosed>
<Description>is closed between W 95th St and W 95th St - closed</Description>
<ToPoint>
<Latitude>38.95653</Latitude>
<Longitude>-94.74221</Longitude>
</ToPoint>
</TrafficIncident>
<TrafficIncident>
<Point>
<Latitude>38.94201</Latitude>
<Longitude>-94.74218</Longitude>
</Point>
<Source>4</Source>
<IncidentId>9000000691</IncidentId>
<LastModifiedUTC>2015-06-24T15:12:15.0238037Z</LastModifiedUTC>
<StartTimeUTC>2015-05-27T17:10:13Z</StartTimeUTC>
<EndTimeUTC>2015-10-05T09:05:00Z</EndTimeUTC>
<Type>Miscellaneous</Type>
<Severity>Serious</Severity>
<Verified>true</Verified>
<RoadClosed>true</RoadClosed>
<Description>is closed between W 103rd St and W 103rd St - closed</Description>
<ToPoint>
<Latitude>38.94201</Latitude>
<Longitude>-94.74218</Longitude>
</ToPoint>
</TrafficIncident>
</Resources>
</ResourceSet>
</ResourceSets>
</Response>
However the results are fluctuating, some times I get 5 results, 1 second later 2 and one second later again the same 5 as before.
Also these fluctuations are regardless of StartTimeUTC, EndTimeUTC which should indicate the start and end of the validity of the Incident report.
Because I need to send alert emails when accidents appear in the result I currently insert the values of IncidentId in an APC array and extract only those with a high hit and dismiss those appearing seldomly.
Anyone knows why this happens and how to solve it efficiently?
EDIT:
To load the xml file I use something like this in PHP5:
$xml = simplexml_load_file("http://dev.virtualearth.net/REST/v1/Traffic/Incidents/37,-105,45,-94?o=xml&severity=3,4&key=#######myapikey######");
I don't see any documentation telling how to set a timeout and so I have the impression that the simplexml_load_file() function should wait for the entire loading of the xml response.