0
我正在解析一个外部xml文件来显示总线如何去。Php simplexml组数据
$xmlurl = 'https://api.trafiklab.se/sl/realtid/GetDpsDepartures.xml?siteId=9520&key=XXX';
$xml = simplexml_load_file($xmlurl);
的结果是这样的:
<buses>
<DpsBus>
<Line>Blue</Line>
<Destination>North</Destination>
<Time>5 min</Time>
<DpsBus>
<DpsBus>
<Line>Green</Line>
<Destination>East</Destination>
<Time>7 min</Time>
<DpsBus>
<DpsBus>
<Line>Blue</Line>
<Destination>North</Destination>
<Time>9 min</Time>
<DpsBus>
...
</buses>
现在我展示的结果是这样的:
$i = 0;
while ($i<100) {
echo $xml->Buses->DpsBus[$i]->Line;
echo $xml->Buses->DpsBus[$i]->Destination;
echo $xml->Buses->DpsBus[$i]->Time;
$i++;
}
但我可以采用某种组此表中的数据?
所以结果如下:
Blue North | 7分钟| 10分钟| 25分钟
Blue South | 5分钟| 15分钟| 25分钟
Green South | 10分钟| 15分钟| 20分钟
任何想法?
'但是我可以采用某种排序此表中的' - 分类标准是什么? –
你可能是指* group *? – hakre
是的,我是meen团体。我现在编辑了我的问题。 – Stichy