地理名称Web服务访问问题 [英] geoname webservice access issue

查看:73
本文介绍了地理名称Web服务访问问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试使用地理名称网络服务访问国家/地区信息.当我在浏览器中键入URL时,我以xml格式获取输出,但是无法从代码中访问相同的URL.

网址是: http://ws.geonames.org/countryInfo?lang=it&country=DE [^ ]

代码:

Hi,

I''m trying to access Country information using geonames webservice. When I type the url in the browser, i''m getting the output in xml format but same url is not accessible from the code.

Url is: http://ws.geonames.org/countryInfo?lang=it&country=DE[^]

code:

XElement rootXml = XElement.Load("http://ws.geonames.org/countryInfo?lang=it&country=DE");

var Countries = from C in rootXml.Elements()
                select new
                {
                  Code = (string)C.Element("countryCode"),
                  Name = (string)C.Element("countryName")
                };

foreach (var x in Countries)
  Console.WriteLine("{0} {1}", x.Code, x.Name);

Console.ReadKey();



执行项目时出现的错误:
无法解析远程名称:"ws.geonames.org"

任何帮助将不胜感激.



Error that i''m getting when the project is executed:
The remote name could not be resolved: ''ws.geonames.org''

Any help would be appreciated.

推荐答案

我将您的代码粘贴到了应用程序中,并且效果很好:
I pasted your code into an app, and it worked fine:
DE Germania

输出到控制台.
您是否尝试过单步踩踏?

output to the console.
Have you tried single stepping?


这篇关于地理名称Web服务访问问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆