如何使用YQL查询使用纬度和经度位置获取国家/地区名称?或者我可以更好地指出找出表的列?
答案 0 :(得分:0)
上述查询确实有效,但让我带您完成所有步骤。
构建对yahoo的url查询并创建请求。
string url = string.Format("http://query.yahooapis.com/v1/public/yql?q={0}", HttpUtility.UrlEncode("SELECT * FROM geo.placefinder WHERE text=\"-27,28\" and gflags=\"r\""));
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
获取响应数据:
using (WebResponse response = request.GetResponse())
{
XmlDocument doc = new XmlDocument();
doc.Load(response.GetResponseStream());
geo.CountryName = doc.SelectSingleNode("./query/results/Result/country").InnerText;
geo.AlphaCode = doc.SelectSingleNode("./query/results/Result/countrycode").InnerText;
geo.City = doc.SelectSingleNode("./query/results/Result/city").InnerText;
geo.State = doc.SelectSingleNode("./query/results/Result/state").InnerText;
}
答案 1 :(得分:-1)
我正在寻找的答案是:
SELECT * FROM geo.placefinder WHERE text=\"{0}\" and gflags=\"r
文字是纬度和经度,例如-27,28
这将返回带有国家/地区信息的xml。