我正在尝试在 Kynetx 应用程序中使用 Yahoo Local Search。
ruleset avogadro {
meta {
name "yahoo-local-ruleset"
description "use results from Yahoo local search"
author "randall bohn"
key yahoo_local "get-your-own-key"
}
dispatch { domain "example.com"}
global {
datasource local:XML <- "http://local.yahooapis.com/LocalSearchService/V3/localsearch";
}
rule add_list {
select when pageview ".*" setting ()
pre {
ds = datasource:local("?appid=#{keys:yahoo_local()}&query=pizza&zip=#{zip}&results=5");
rs = ds.pick("$..Result");
}
append("body","<ul id='my_list'></ul>");
always {
set ent:pizza rs;
}
}
rule add_results {
select when pageview ".*" setting ()
foreach ent:pizza setting pizza
pre {
title = pizza.pick("$..Title");
}
append("#my_list", "<li>#{title}</li>");
}
}
我最终得到的清单是
. [object Object]
和“标题”有
{'$t' => 'Pizza Shop 1'}
我无法弄清楚如何获得标题。看起来原始 XML 文件中的“文本内容”变成了 {'$t' => 'text content'},而 '$t' 给 pick() 带来了问题。