我尝试从 XML 文件中获取数据。数据如下所示:
<MeasuringPoints>
<MeasuringPoint ID="Base" LastChange="2013-05-17T09:29:59.293" WeatherCondition="8">
<Name LngID="IT">Name 1</Name>
<Name LngID="DE">Name 2</Name>
<Name LngID="EN>Name 3</Name>
</MeasuringPoint>
<MeasuringPoint ID="Middle" LastChange="2012-08-01T11:47:33.160" WeatherCondition="14">
<Name LngID="IT">Name 1a</Name>
<Name LngID="DE">Name 2a</Name>
<Name LngID="EN">Name 3a</Name>
</MeasuringPoint>
<MeasuringPoint ID="Top" LastChange="2013-05-17T09:29:59.293" WeatherCondition="8">
<Name LngID="DE">Name 1b</Name>
<Name LngID="IT">Name 2b</Name>
<Name LngID="EN">Name 3b</Name>
</MeasuringPoint>
</MeasuringPoints>
我也有这个 php 代码:
foreach ($xml->Area as $area)
{
$MEASURING_POINTS = $area->MeasuringPoints->MeasuringPoint['ID'];
$MEASURING_LAST_CHANGE = $area->MeasuringPoints->MeasuringPoint['LastChange'];
echo $MEASURING_POINTS;
echo " - ";
echo $MEASURING_LAST_CHANGE;
}
该代码有效,但仅适用于第一个MeasuringPoint
(Base
ID)。
如何从其他MeasuringPoint
(Middle
和Top
ID)获取数据?
谢谢你的帮助!
阿德里安