在Swift中解析天气XML数据

时间:2017-08-01 17:14:23

标签: xml swift swift3 xml-parsing weather

我是webservices的新手,并试图解析从天气网站收到的一些xml数据。这个结构对我来说不同于openweathermap api返回的其他xml数据。我应该如何处理这些节点和元组列表以匹配DataRecord中所有参数的值?一个参数如'温度'有几个重复的值..

<gml:rangeSet>
<gml:DataBlock>
<gml:rangeParameters/>
<gml:doubleOrNilReasonTupleList>
113.01 20.03 1013.89 53.37 234.0 4.38 2.44 3.64 6.28 8.76 6.81 35.1 2.0 30.2 10.0 0.0 0.0 0.0 6852076.5 6429906.5 -1344119.25 6131957.5 3122299.25 113.01 19.16 1014.14 59.56 223.0 3.59 1.36 3.31 6.28 6.94 8.23 80.0 3.0 64.9 10.0 0.0 0.0 0.0 7114915.5 7732196.5 -1553170.88 6363484.0 3291196.5 113.01 17.73 1014.33 69.87 209.0 3.05 0.45 3.04 3.56 5.8 10.15 11.9 1.0 6.8 0.0 0.0 0.0 0.0 7158493.5 8958460.0 -1820905.13 6399564.5 3334774.5 113.01 16.32 1014.4 80.78 197.0 2.91 -0.19 2.91 3.55 5.47 11.8 55.5 2.0 0.0 0.0 51.2 0.0 0.0 7158493.5 10136144.0 -2121490.0 6399564.5 3334774.5 113.01 15.71 1014.52 88.46 199.0 3.37 -0.01 3.37 3.55 6.52 13.11 100.0 3.0 0.0 0.0 100.0 0.0 0.0 7155351.5 11316823.0 -2407310.5 6400342.0 3335817.5 113.01 15.17 1014.64 93.19 199.0 2.99 -0.12 3.01 3.55 5.91 13.68 88.9 3.0 0.6 0.0 94.9 0.0 0.0 7156596.5 12520698.0 -2668392.5 6399287.5 3332406.25 113.01 14.4 1014.3 97.24 189.0 2.25 -0.52 2.19 3.56 4.26 13.81 90.6 3.0 18.9 8.9 90.6 0.0 0.0 7158433.0 13713832.0 -2929743.0 6398189.5 3334714.25
</gml:doubleOrNilReasonTupleList>
</gml:DataBlock>
</gml:rangeSet>
<gml:coverageFunction>
<gml:CoverageMappingRule>
<gml:ruleDefinition>Linear</gml:ruleDefinition>
</gml:CoverageMappingRule>
</gml:coverageFunction>
<gmlcov:rangeType>
<swe:DataRecord>
<swe:field name="GeopHeight" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=GeopHeight&language=eng"/>
<swe:field name="Temperature" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=Temperature&language=eng"/>
<swe:field name="Pressure" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=Pressure&language=eng"/>
<swe:field name="Humidity" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=Humidity&language=eng"/>
<swe:field name="WindDirection" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=WindDirection&language=eng"/>
<swe:field name="WindSpeedMS" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=WindSpeedMS&language=eng"/>
<swe:field name="WindUMS" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=WindUMS&language=eng"/>
<swe:field name="WindVMS" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=WindVMS&language=eng"/>
<swe:field name="MaximumWind" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=MaximumWind&language=eng"/>
<swe:field name="WindGust" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=WindGust&language=eng"/>
<swe:field name="DewPoint" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=DewPoint&language=eng"/>
<swe:field name="TotalCloudCover" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=TotalCloudCover&language=eng"/>
<swe:field name="WeatherSymbol3" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=WeatherSymbol3&language=eng"/>
<swe:field name="LowCloudCover" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=LowCloudCover&language=eng"/>
<swe:field name="MediumCloudCover" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=MediumCloudCover&language=eng"/>
<swe:field name="HighCloudCover" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=HighCloudCover&language=eng"/>
<swe:field name="Precipitation1h" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=Precipitation1h&language=eng"/>
<swe:field name="PrecipitationAmount" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=PrecipitationAmount&language=eng"/>
<swe:field name="RadiationGlobalAccumulation" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=RadiationGlobalAccumulation&language=eng"/>
<swe:field name="RadiationLWAccumulation" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=RadiationLWAccumulation&language=eng"/>
<swe:field name="RadiationNetSurfaceLWAccumulation" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=RadiationNetSurfaceLWAccumulation&language=eng"/>
<swe:field name="RadiationNetSurfaceSWAccumulation" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=RadiationNetSurfaceSWAccumulation&language=eng"/>
<swe:field name="RadiationDiffuseAccumulation" xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&param=RadiationDiffuseAccumulation&language=eng"/>
</swe:DataRecord>
</gmlcov:rangeType>
</gmlcov:MultiPointCoverage>
</om:result>

0 个答案:

没有答案