我刚开始研究 NDFD REST 服务以获取天气数据。简而言之,我不知道如何将特定参数链接到返回 XML 中的时间布局元素。
我正在使用此调用查找最高温度(maxt)、最低温度(mint)和 3 小时温度(temp)。
我得到的 XML 是(为了相关性而剪掉的):
<?xml version="1.0"?>
<dwml version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://graphical.weather.gov/xml/DWMLgen/schema/DWML.xsd">
<head>
<product srsName="WGS 1984" concise-name="time-series" operational-mode="official">
<title>NOAA's National Weather Service Forecast Data</title>
<field>meteorological</field>
<category>forecast</category>
<creation-date refresh-frequency="PT1H">2012-12-26T20:03:47Z</creation-date>
</product>
<source>
<more-information>http://graphical.weather.gov/xml/</more-information>
<production-center>Meteorological Development Laboratory<sub-center>Product Generation Branch</sub-center></production-center>
<disclaimer>http://www.nws.noaa.gov/disclaimer.html</disclaimer>
<credit>http://www.weather.gov/</credit>
<credit-logo>http://www.weather.gov/images/xml_logo.gif</credit-logo>
<feedback>http://www.weather.gov/feedback.php</feedback>
</source>
</head>
<data>
<location>
<location-key>point1</location-key>
<point latitude="38.99" longitude="-77.01"/>
</location>
<moreWeatherInformation applicable-location="point1">http://forecast.weather.gov/MapClick.php?textField1=38.99&textField2=-77.01</moreWeatherInformation>
<time-layout time-coordinate="local" summarization="none">
<layout-key>k-p24h-n7-1</layout-key>
<start-valid-time>2012-12-26T07:00:00-05:00</start-valid-time>
<end-valid-time>2012-12-26T19:00:00-05:00</end-valid-time>
</time-layout>
<time-layout time-coordinate="local" summarization="none">
<layout-key>k-p24h-n6-2</layout-key>
<start-valid-time>2012-12-26T19:00:00-05:00</start-valid-time>
<end-valid-time>2012-12-27T08:00:00-05:00</end-valid-time>
</time-layout>
<time-layout time-coordinate="local" summarization="none">
<layout-key>k-p3h-n34-3</layout-key>
<start-valid-time>2012-12-26T16:00:00-05:00</start-valid-time>
<start-valid-time>2012-12-26T19:00:00-05:00</start-valid-time>
<start-valid-time>2012-12-26T22:00:00-05:00</start-valid-time>
<start-valid-time>2012-12-27T01:00:00-05:00</start-valid-time>
</time-layout>
<parameters applicable-location="point1">
<temperature type="maximum" units="Fahrenheit" time-layout="k-p24h-n7-1">
<name>Daily Maximum Temperature</name>
<value>34</value>
</temperature>
<temperature type="minimum" units="Fahrenheit" time-layout="k-p24h-n6-2">
<name>Daily Minimum Temperature</name>
<value>34</value>
</temperature>
<temperature type="hourly" units="Fahrenheit" time-layout="k-p3h-n34-3">
<name>Temperature</name>
<value>33</value>
<value>34</value>
<value>34</value>
<value>34</value>
</temperature>
</parameters>
</data>
</dwml>
现在,我想将time-layout
元素和元素的子元素链接parameters
到 maxt、mint 和 temp,以便我可以相应地填充我的模型对象。
有没有人做过类似的事情?
现在,我认为我可以发出 53 个服务调用(每个参数一个,如 maxt、mint、temp 等),但对于多个纬度/经度对(我有很多),这不会很好地扩展。
我将不胜感激任何建议。