【发布时间】:2012-03-21 20:30:55
【问题描述】:
我收到了一些来自 XML 和 RSS 的 YQL 查询,这些查询返回的结果比我想要的更多 SELECT。我将所有 XML 从 itemPath 获取到属性值,然后我必须筛选出我想要的值:
这个查询:
SELECT current_conditions.temp_c.data FROM xml
WHERE url="http://www.google.com/ig/api?weather=Tbilisi"
AND itemPath="//weather"
返回所有这些:
<results>
<weather>
<current_conditions>
<temp_c data="-7"/>
</current_conditions>
</weather>
</results>
但我只需要:
<results>-7</results>
这个查询:
SELECT condition.temp FROM rss
WHERE url="http://weather.yahooapis.com/forecastrss?w=1965878&u=c"
返回所有这些:
<results>
<item>
<yweather:condition
xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" temp="1"/>
</item>
</results>
而我想要的只是这个:
<results>1</results>
在使用 YQL 选择 XML 属性时,有什么方法可以得到更简洁的结果,这样我就不必在代码中进一步解析结果了?
一个用例是我想使用yql.query.multi 在一个查询中查询多个源。当所有这些周围的 XML 都返回给我时,我没有得到一个漂亮整洁的“行”。
【问题讨论】:
标签: xml rss yql xml-attribute google-weather-api