我正在实施一项方案,从XML档案中收集气象数据。 我尤其希望通过如下文中提及的档案,为特定地点提供风能统计数据。
位置在观察标的元数据中以名称表示“站-名称”。 风力数据载于观测和观测;元素。
多个名称空间的使用似乎使我对如何使用简单的xml文件的了解有限。
我正在尝试用一个Xml文档:。
我已把测试削减到一个观察点(以下各点):
<?xml version="1.0" encoding="UTF-8"?>
<om:ObservationCollection xmlns:om="http://www.opengis.net/om/1.0" xmlns="http://dms.ec.gc.ca/schema/point-observation/2.0" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<om:member>
<om:Observation>
<om:metadata>
<set><general><author name="MSC-DMS-PG-WXO-HOURLY" version="1.5"/><dataset name="msc/observation/atmospheric/surface_weather/wxo-2.0-ascii"/><phase name="product-hourly_en-xml-2.0"/><id xlink:href="/data/msc/observation/atmospheric/surface_weather/wxo-2.0-ascii/product-hourly_en-xml-2.0/201105072356/mb"/><parent xlink:href="/data/msc/observation/atmospheric/surface_weather/cs-1.0-binary/decoded-xml-2.0/201105072300/cpgh"/></general>
<identification-elements>
<element name="station_name" uom="unitless" value="Gimli"/>
<element name="latitude" uom="degree" value="50.63"/>
<element name="longitude" uom="degree" value="-97.05"/>
<element name="transport_canada_id" uom="unitless" value="PGH"/>
<element name="observation_date_utc" uom="unitless" value="2011-05-07T23:00:00.000Z"/>
<element name="observation_date_local_time" uom="unitless" value="2011-05-07T18:00:00.000 CDT"/>
<element name="climate_station_number" uom="unitless" value="5031042"/>
<element name="wmo_station_number" uom="unitless" value="71748"/>
</identification-elements>
</set>
</om:metadata>
<om:samplingTime><gml:TimeInstant><gml:timePosition>2011-05-07T23:00:00.000Z</gml:timePosition></gml:TimeInstant></om:samplingTime>
<om:resultTime><gml:TimeInstant><gml:timePosition>2011-05-07T23:56:09.099Z</gml:timePosition></gml:TimeInstant></om:resultTime>
<om:procedure xlink:href=""/>
<om:observedProperty gml:remoteSchema="/schema/point-observation/2.0.xsd"/>
<om:featureOfInterest>
<gml:FeatureCollection>
<gml:location><gml:Point><gml:pos>50.63333333333333 -97.05</gml:pos></gml:Point></gml:location>
</gml:FeatureCollection>
</om:featureOfInterest>
<om:result>
<orig-header/>
<elements>
<element name="present_weather" uom="code" value=""/>
<element name="mean_sea_level" uom="kPa" value="100.89"/>
<element name="tendency_amount" uom="kPa" value="0.07"/>
<element name="tendency_characteristic" uom="code" value="rising"/>
<element name="horizontal_visibility" uom="km" value=""/>
<element name="air_temperature" uom="Celsius" value="11.4"/>
<element name="dew_point" uom="Celsius" value="8.2"/>
<element name="relative_humidity" uom="percent" value="81.0"/>
<element name="wind_speed" uom="km/h" value="24.8"/>
<element name="wind_direction" uom="code" value="SW"/>
<element name="wind_gust_speed" uom="km/h" value="36.4"/>
<element name="total_cloud_cover" uom="code" value=""/>
<element name="wind_chill" uom="unitless" value=""/>
<element name="humidex" uom="unitless" value=""/>
</elements>
</om:result>
</om:Observation>
</om:member>
</om:ObservationCollection>
这是我迄今为止所做的事情,它正正式让我看不到......。
<?php
$xml = simplexml_load_file("weather.xml");
foreach($xml->item as $item){
$collection = $item->children("http://www.opengis.net/om/1.0");
}
print_r($collection->member);
?>