Согласно другому вопросу я могу выбрать отдельные поля XML с помощью запроса YQL и он отлично работает, когда я тестирую его:
SELECT statistics.subscriberCount FROM xml
WHERE url='http://gdata.youtube.com/feeds/api/users/{$id}'
Однако, когда я пытаюсь выбрать отдельные XML-поля из «неофициального» XML API погоды Google Я всегда получаю пустые результаты (хотя SELECT *
работает).
Я знаю, что мое понимание как XML, так и YQL не является полным, но что мне не хватает? (Вот мой запрос в консоли YQL)
(Мне удалось запросить его с помощью XPATH с параметром itemPath
и SELECT *
)
Мой предполагаемый запрос
SELECT current_conditions FROM xml
WHERE url="http://www.google.com/ig/api?weather=Tbilisi"
Результаты
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
yahoo:count="0" yahoo:created="2012-02-27T11:56:15Z" yahoo:lang="en-US">
<results/>
</query>
Результаты SELECT *
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
yahoo:count="1" yahoo:created="2012-02-27T11:57:18Z" yahoo:lang="en-US">
<results>
<xml_api_reply version="1">
<weather mobile_row="0" mobile_zipped="1" module_id="0"
row="0" section="0" tab_id="0">
<forecast_information>
<city data="Tbilisi, Tbilisi"/>
<postal_code data="Tbilisi"/>
<latitude_e6 data=""/>
<longitude_e6 data=""/>
<forecast_date data="2012-02-27"/>
<current_date_time data="1970-01-01 00:00:00 +0000"/>
<unit_system data="US"/>
</forecast_information>
<current_conditions>
<condition data="Overcast"/>
<temp_f data="34"/>
<temp_c data="1"/>
<humidity data="Humidity: 80%"/>
<icon data="/ig/images/weather/cloudy.gif"/>
<wind_condition data="Wind: NE at 6 mph"/>
</current_conditions>
<forecast_conditions>
<day_of_week data="Mon"/>
<low data="28"/>
<high data="37"/>
<icon data="/ig/images/weather/mostly_sunny.gif"/>
<condition data="Mostly Sunny"/>
</forecast_conditions>
<forecast_conditions>
<day_of_week data="Tue"/>
<low data="30"/>
<high data="41"/>
<icon data="/ig/images/weather/mostly_sunny.gif"/>
<condition data="Mostly Sunny"/>
</forecast_conditions>
<forecast_conditions>
<day_of_week data="Wed"/>
<low data="30"/>
<high data="43"/>
<icon data="/ig/images/weather/mostly_sunny.gif"/>
<condition data="Mostly Sunny"/>
</forecast_conditions>
<forecast_conditions>
<day_of_week data="Thu"/>
<low data="27"/>
<high data="43"/>
<icon data="/ig/images/weather/mostly_sunny.gif"/>
<condition data="Partly Sunny"/>
</forecast_conditions>
</weather>
</xml_api_reply>
</results>
</query>