Javascript 创建YQL Opentable以将RSS数据与Placemaker地图信息相结合
我试图从RSS提要中检索数据(本部分随后介绍),然后使用YQL Placemaker open datatable使用描述、标题和标题来获取地理信息(纬度、经度、woeId) 这就是作为JSON输出所需的全部内容 在YQL控制台中测试它的永久链接是 你知道我的xml代码有什么问题吗?或者我应该尝试什么Javascript 创建YQL Opentable以将RSS数据与Placemaker地图信息相结合,javascript,json,datatable,yql,geo,Javascript,Json,Datatable,Yql,Geo,我试图从RSS提要中检索数据(本部分随后介绍),然后使用YQL Placemaker open datatable使用描述、标题和标题来获取地理信息(纬度、经度、woeId) 这就是作为JSON输出所需的全部内容 在YQL控制台中测试它的永久链接是 你知道我的xml代码有什么问题吗?或者我应该尝试什么 雅虎!股份有限公司。 http://i-magine.mobi/ 从{table}中选择*,其中section=“topstories”和description匹配“*jpg.*” 搜索雅虎
雅虎!股份有限公司。
http://i-magine.mobi/
从{table}中选择*,其中section=“topstories”和description匹配“*jpg.*”
搜索雅虎新闻RSS
http://rss.news.yahoo.com/rss/topstories/{section}
您的表的整洁(并且“工作”在某种意义上,它带来了RSS+Placemaker结果)版本如下所示:
<?xml version="1.0" encoding="UTF-8" ?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>Peter Cowburn</author>
<documentationURL>http://stackoverflow.com/questions/6168564/creating-a-yql-opentable-to-combine-rss-data-with-placemaker-map-info</documentationURL>
<sampleQuery>select * from {table} where section='topstories'</sampleQuery>
<description>Searches Yahoo! News RSS and injects Placemaker Places</description>
</meta>
<bindings>
<select itemPath="stories.story" produces="XML">
<urls>
<url>
http://rss.news.yahoo.com/rss/{section}
</url>
</urls>
<inputs>
<key id="section" type="xs:string" paramType="path" required="true" />
</inputs>
<execute><![CDATA[
// Fetch top 30 feed items with jpg images
var feed = y.query(
'select * from rss where url=@url and description matches ".*jpg.*" limit 30',
{url: request.url}
).results;
// Build geo queries
var placeQuery = 'select * from geo.placemaker where documentContent=@text and documentType="text/plain"';
var placeQueries = [];
var title, description, caption, summary, content;
for each (result in feed.item) {
title = result.title.text().toString();
description = y.tidy(result.description.toString()).body.p;
caption = description.a.img.@alt.toString();
summary = description..*.text().toString();
content = caption + " " + title + " " + summary;
placeQueries.push({
query: y.query(placeQuery, {text: content}),
item: result,
results: null
});
}
// Execute all queries
var where = new Namespace('http://wherein.yahooapis.com/v1/schema');
var matches, match, places = [];
for (var q in placeQueries) {
matches = placeQueries[q].query.results.matches.match;
placeQueries[q].results = matches..where::place;
}
// Build response object
var stories = <stories/>;
for each (q in placeQueries) {
stories.node += <story>
{q.item}
{q.results}
</story>;
}
response.object = stories;
]]></execute>
</select>
</bindings>
</table>
()
该表使用了
块中可用的一些功能,如E4X、查询参数和并行查询,这些功能使生活更轻松,但乍一看可能有些陌生
另外,上面的内容是按原样提供的,我不打算在这个问题上反复回答“支持”问题。主要目的是让你行动起来,介绍一种可能适合你的方法。嗨,伊姆兰,主要问题是你的
块有点混乱。你想做的是很有可能的,你自己做了吗?
<?xml version="1.0" encoding="UTF-8" ?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>Peter Cowburn</author>
<documentationURL>http://stackoverflow.com/questions/6168564/creating-a-yql-opentable-to-combine-rss-data-with-placemaker-map-info</documentationURL>
<sampleQuery>select * from {table} where section='topstories'</sampleQuery>
<description>Searches Yahoo! News RSS and injects Placemaker Places</description>
</meta>
<bindings>
<select itemPath="stories.story" produces="XML">
<urls>
<url>
http://rss.news.yahoo.com/rss/{section}
</url>
</urls>
<inputs>
<key id="section" type="xs:string" paramType="path" required="true" />
</inputs>
<execute><![CDATA[
// Fetch top 30 feed items with jpg images
var feed = y.query(
'select * from rss where url=@url and description matches ".*jpg.*" limit 30',
{url: request.url}
).results;
// Build geo queries
var placeQuery = 'select * from geo.placemaker where documentContent=@text and documentType="text/plain"';
var placeQueries = [];
var title, description, caption, summary, content;
for each (result in feed.item) {
title = result.title.text().toString();
description = y.tidy(result.description.toString()).body.p;
caption = description.a.img.@alt.toString();
summary = description..*.text().toString();
content = caption + " " + title + " " + summary;
placeQueries.push({
query: y.query(placeQuery, {text: content}),
item: result,
results: null
});
}
// Execute all queries
var where = new Namespace('http://wherein.yahooapis.com/v1/schema');
var matches, match, places = [];
for (var q in placeQueries) {
matches = placeQueries[q].query.results.matches.match;
placeQueries[q].results = matches..where::place;
}
// Build response object
var stories = <stories/>;
for each (q in placeQueries) {
stories.node += <story>
{q.item}
{q.results}
</story>;
}
response.object = stories;
]]></execute>
</select>
</bindings>
</table>
use 'https://raw.github.com/salathe/yql-tables/so-6168564/yahoo/newswithplaces.xml'
as rssplaces;
select * from rssplaces where section='topstories';