PHP echo objects from an XML document where there are duplicate nodes



I have been using the Bing Maps API to get traffic incidents from a certain area. This would then create an XML document, I can access objects that are single nodes but can't echo any nodes that are nested within other nodes. The XML document looks like:



<Response xmlns:xsd="http://ift.tt/tphNwY" xmlns:xsi="http://ift.tt/ra1lAU"
xmlns="http://ift.tt/1prkLAu">
<Copyright>
- Message -
</Copyright>
<BrandLogoUri>
- Logo -
</BrandLogoUri>
<StatusCode>200</StatusCode>
<StatusDescription>OK</StatusDescription>
<AuthenticationResultCode>ValidCredentials</AuthenticationResultCode>
<TraceId>
- Trace ID-
</TraceId>
<ResourceSets>
<ResourceSet>
<EstimatedTotal>1</EstimatedTotal>
<Resources>
<TrafficIncident>
<Point>
<Latitude> - Latitude - </Latitude>
<Longitude>- Longitude -</Longitude>
</Point>
<IncidentId>- IncidentId -</IncidentId>
<LastModifiedUTC>- Time -</LastModifiedUTC>
<StartTimeUTC>- Time -</StartTimeUTC>
<EndTimeUTC>- Time -</EndTimeUTC>
<Type>- Type -</Type>
<Severity>- Severity -</Severity>
<Verified>- True -</Verified>
<RoadClosed>- True -</RoadClosed>
<Description>
- Description -
</Description>
<ToPoint>
<Latitude>-Latitude -</Latitude>
<Longitude>- Longitude -</Longitude>
</ToPoint>
</TrafficIncident>
</Resources>
</ResourceSet>
</ResourceSets>
</Response>


To echo the objects in a single node I have been using the following PHP Code: "; echo $xml->TraceId . "

"; echo $xml->Copyright . "

"; echo $xml->Verified . "

"; ?> To echo the Latitude which is in a nested node I have tried the PHP code: foreach($xml->TrafficIncident->Point->Latitude as $row){ echo''.$row.''; }


But so far no luck. Any Ideas?


No comments:

Post a Comment