从天气API过滤特定date的XML
如何从Excel中筛选特定date的XML中的XML?
http://api.openweathermap.org/data/2.5/forecast/daily?q=London&mode=xml&units=metric&cnt=16
B10单元格中的具体date是2015-10-01,API提供了16天的预测数据。 我需要获取特定date的温度,湿度,符号名称和降水量。
我尝试了= FILTERXML(),但我找不到xpath。
应该是这样的:
E10
公式向下:
=FILTERXML(WEBSERVICE("http://api.openweathermap.org/data/2.5/forecast/daily?q=London&mode=xml&units=metric&cnt=16"),"/weatherdata/forecast/time[@day='"&TEXT($B$10,"YYYY-MM-DD")&"']/"&$C10&"/@"&$D10)
但是,Web服务的数据正在不断变化。
XML示例:
<weatherdata> <location><name>London</name><type/><country>GB</country><timezone/><location altitude="0" latitude="51.50853" longitude="-0.12574" geobase="geonames" geobaseid="2643743"/></location><credit/><meta><lastupdate/><calctime>0.0117</calctime><nextupdate/></meta><sun rise="2015-09-20T05:43:44" set="2015-09-20T18:02:55"/> <forecast> <time day="2015-09-20"> <symbol number="800" name="sky is clear" var="01d"/> <precipitation/> <windDirection deg="243" code="WSW" name="West-southwest"/> <windSpeed mps="3.96" name="Gentle Breeze"/> <temperature day="19.43" min="12.68" max="19.73" night="12.68" eve="17.24" morn="19.43"/> <pressure unit="hPa" value="1031.17"/> <humidity value="80" unit="%"/> <clouds value="clear sky" all="0" unit="%"/> </time>
XPATH到日间气温2015-09-20:
/weatherdata/forecast/time[@day='2015-09-20']/temperature/@day