【问题标题】:Extracting Lat/Long from Bing Geocoding service从 Bing 地理编码服务中提取纬度/经度
【发布时间】:2010-12-07 10:32:32
【问题描述】:

我正在尝试使用 linq to xml 提取纬度和经度信息,但由于某种原因,我的努力失败了,我无法调试 linq 语句,这是返回 XML 的 URL:

http://dev.virtualearth.net/REST/v1/Locations/UK/ST104DB?o=xml&key=AsXXdDNPzhinQEhfr9DJe_auOyXAsHr_jF8O0cjGJZDSayU8zedGhy8Vu2PzKTB9

请有人告诉我一个适当的 linq 语句来提取纬度和经度值

谢谢

【问题讨论】:

    标签: c# xml linq-to-xml geocoding


    【解决方案1】:

    这是我的第一次尝试

    var xml = XDocument.Load(@"c:\temp\geo.xml"); // or from stream or wherever
    
    XNamespace ns = "http://schemas.microsoft.com/search/local/ws/rest/v1";
    var points = (from p in xml.Descendants(ns + "Point")
                  select new
                          {
                            Lat = (double) p.Element(ns + "Latitude"),
                            Long = (double) p.Element(ns + "Longitude")
                          })
                   .ToList();
    

    可能有更好、更安全的方法来做到这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多